Commit caa2df5f by liulongfei

1. 添加边线检测场景

2. 算法配置缓存
parent 3b537ef3
......@@ -33,11 +33,13 @@ namespace VIZ.H2V.Connection
/// <param name="manager">UDP终结点管理器</param>
/// <param name="id">算法ID</param>
/// <param name="enable_sendto_crop">是否向裁切程序发送坐标</param>
public static void CenterMode(UdpEndpointManager manager, string id, bool enable_sendto_crop)
/// <param name="smooth">平滑系数</param>
public static void CenterMode(UdpEndpointManager manager, string id, bool enable_sendto_crop, double smooth)
{
AlgorithmPackage__center_mode package = new AlgorithmPackage__center_mode();
package.id = id;
package.enable_sendto_crop = enable_sendto_crop ? 1 : 0;
package.smooth = smooth;
manager.SendJson(package);
}
......@@ -49,12 +51,14 @@ namespace VIZ.H2V.Connection
/// <param name="id">算法ID</param>
/// <param name="roi">手动裁切坐标</param>
/// <param name="enable_sendto_crop">是否向裁切程序发送坐标</param>
public static void ManualMode(UdpEndpointManager manager, string id, bool enable_sendto_crop, List<int> roi)
/// <param name="smooth">平滑系数</param>
public static void ManualMode(UdpEndpointManager manager, string id, bool enable_sendto_crop, List<int> roi, double smooth)
{
AlgorithmPackage__manual_mode package = new AlgorithmPackage__manual_mode();
package.id = id;
package.roi = roi;
package.enable_sendto_crop = enable_sendto_crop ? 1 : 0;
package.smooth = smooth;
manager.SendJson(package);
}
......
......@@ -37,5 +37,10 @@ namespace VIZ.H2V.Connection
/// 是否向裁切程序发送坐标(1:需要, 0: 不需要)
/// </summary>
public int enable_sendto_crop { get; set; }
/// <summary>
/// 边线检测场景
/// </summary>
public string border_scene { get; set; }
}
}
......@@ -21,5 +21,10 @@ namespace VIZ.H2V.Connection
/// 是否向裁切程序发送坐标(1:需要, 0: 不需要)
/// </summary>
public int enable_sendto_crop { get; set; }
/// <summary>
/// 平滑系数
/// </summary>
public double smooth { get; set; }
}
}
......@@ -26,5 +26,10 @@ namespace VIZ.H2V.Connection
/// 是否向裁切程序发送坐标(1:需要, 0: 不需要)
/// </summary>
public int enable_sendto_crop { get; set; }
/// <summary>
/// 平滑系数
/// </summary>
public double smooth { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.H2V.Domain
{
/// <summary>
/// 算法边线场景模型
/// </summary>
public class AlgorithmBorderScenceModel : ModelBase
{
#region ID -- 编号
private int id;
/// <summary>
/// 编号
/// </summary>
public int ID
{
get { return id; }
set { id = value; this.RaisePropertyChanged(nameof(ID)); }
}
#endregion
#region Key --
private string key;
/// <summary>
/// 键
/// </summary>
public string Key
{
get { return key; }
set { key = value; this.RaisePropertyChanged(nameof(Key)); }
}
#endregion
#region DisplayName -- 显示名称
private string displayName;
/// <summary>
/// 显示名称
/// </summary>
public string DisplayName
{
get { return displayName; }
set { displayName = value; this.RaisePropertyChanged(nameof(DisplayName)); }
}
#endregion
}
}
......@@ -75,6 +75,7 @@
<Compile Include="Message\Algorithm\AlgorithmMessage__checked_ok.cs" />
<Compile Include="Message\NDI\AlgorithmStrategyChangedToManualMessage.cs" />
<Compile Include="Model\Algorithm\AlgorithmProcessModel.cs" />
<Compile Include="Model\Algorithm\AlgorithmBorderScenceModel.cs" />
<Compile Include="Model\Algorithm\AlgorithmStrategyModel.cs" />
<Compile Include="Model\NDI\NDIStreamInfoModel.cs" />
<Compile Include="Model\NDI\NDIStreamDelayInfoModel.cs" />
......
......@@ -290,15 +290,21 @@ namespace VIZ.H2V.Module
if (this.hotkeyController == null)
return;
WPFHelper.BeginInvoke(() =>
{
Window window = Window.GetWindow(this.GetView<NDIMainView>());
if (window == null)
return;
Window window = Window.GetWindow(this.GetView<NDIMainView>());
if (window == null)
return;
if (!window.IsActive)
return;
if (!window.IsActive)
return;
// 屏蔽空格键
if (e.KeyCode == System.Windows.Forms.Keys.Space)
{
e.Handled = true;
}
WPFHelper.BeginInvoke(() =>
{
// 空格键特殊处理
if (e.KeyCode == System.Windows.Forms.Keys.Space)
{
......
......@@ -38,6 +38,7 @@
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 无球时自动跟人 -->
......@@ -142,6 +143,27 @@
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<!-- 场景 -->
<Grid Grid.Row="7">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="380"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="场景" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="6"></TextBlock>
<ComboBox Grid.Column="1" Style="{StaticResource ComboBox_Setting}" Height="40"
ItemsSource="{Binding Path=BorderScences,Mode=OneWay}"
SelectedValue="{Binding Path=SelectedBorderScence,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent" IsHitTestVisible="False">
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center" HorizontalAlignment="Left"
Grid.Column="3" Foreground="White" FontSize="14"></TextBlock>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</Grid>
</Border>
</UserControl>
\ No newline at end of file
......@@ -143,6 +143,27 @@
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<!-- 场景 -->
<Grid Grid.Row="7">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="380"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="场景" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="6"></TextBlock>
<ComboBox Grid.Column="1" Style="{StaticResource ComboBox_Setting}" Height="40"
ItemsSource="{Binding Path=BorderScences,Mode=OneWay}"
SelectedValue="{Binding Path=SelectedBorderScence,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent" IsHitTestVisible="False">
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center" HorizontalAlignment="Left"
Grid.Column="3" Foreground="White" FontSize="14"></TextBlock>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</Grid>
</Border>
</UserControl>
......@@ -35,6 +35,7 @@
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 平滑系数 -->
......@@ -103,6 +104,27 @@
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<!-- 场景 -->
<Grid Grid.Row="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="380"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="场景" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="6"></TextBlock>
<ComboBox Grid.Column="1" Style="{StaticResource ComboBox_Setting}" Height="40"
ItemsSource="{Binding Path=BorderScences,Mode=OneWay}"
SelectedValue="{Binding Path=SelectedBorderScence,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent" IsHitTestVisible="False">
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center" HorizontalAlignment="Left"
Grid.Column="3" Foreground="White" FontSize="14"></TextBlock>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</Grid>
</Border>
</UserControl>
......@@ -152,12 +152,12 @@
</Grid.ColumnDefinitions>
<TextBlock Text="场景" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="6"></TextBlock>
<ComboBox Grid.Column="1" Style="{StaticResource ComboBox_Setting}" Height="40"
ItemsSource="{Binding Path=Scences,Mode=OneWay}"
SelectedValue="{Binding Path=SelectedScence,Mode=TwoWay}">
ItemsSource="{Binding Path=BorderScences,Mode=OneWay}"
SelectedValue="{Binding Path=SelectedBorderScence,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent" IsHitTestVisible="False">
<TextBlock Text="{Binding .}" VerticalAlignment="Center" HorizontalAlignment="Left"
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center" HorizontalAlignment="Left"
Grid.Column="3" Foreground="White" FontSize="14"></TextBlock>
</Grid>
</DataTemplate>
......
......@@ -38,6 +38,7 @@
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 无球时自动跟人 -->
......@@ -142,6 +143,27 @@
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<!-- 场景 -->
<Grid Grid.Row="7">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="380"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="场景" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="6"></TextBlock>
<ComboBox Grid.Column="1" Style="{StaticResource ComboBox_Setting}" Height="40"
ItemsSource="{Binding Path=BorderScences,Mode=OneWay}"
SelectedValue="{Binding Path=SelectedBorderScence,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent" IsHitTestVisible="False">
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center" HorizontalAlignment="Left"
Grid.Column="3" Foreground="White" FontSize="14"></TextBlock>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</Grid>
</Border>
</UserControl>
\ No newline at end of file
......@@ -141,12 +141,7 @@ namespace VIZ.H2V.Module
this.KeepPrevFrame = config.KeepPrevFrame;
// 场景信息
AlgorithmStrategy strategy = ApplicationDomainEx.CsvContext.AlgorithmStrategys.FirstOrDefault(p => p.ID == (int)this.StrategyType);
if (strategy == null)
return;
this.Scences = strategy.Scenes?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)?.ToList();
this.SelectedScence = (this.Scences?.Contains(this.Config.Scene) == true) ? this.Config.Scene : this.Scences?.FirstOrDefault();
this.SelectedBorderScence = this.BorderScences?.FirstOrDefault(p => p.Key == this.Config.BorderScene) ?? this.BorderScences?.FirstOrDefault();
}
/// <summary>
......@@ -185,7 +180,7 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
if (this.SelectedBorderScence.Key != this.Config.BorderScene)
return true;
return false;
......@@ -200,9 +195,6 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
return true;
return false;
}
......@@ -227,7 +219,7 @@ namespace VIZ.H2V.Module
this.Config.NoBallAutoChangeToPerson = this.NoBallAutoChangeToPerson;
this.Config.SmoothCoeff = this.SmoothCoeff;
this.Config.KeepPrevFrame = this.KeepPrevFrame;
this.Config.Scene = this.SelectedScence;
this.Config.BorderScene = this.SelectedBorderScence.Key;
this.ViewConfig.GPU = this.SelectedGpuInfo?.Physics ?? 0;
ApplicationDomainEx.LiteDbContext.AlgorithmCableway.Upsert(this.Config);
......@@ -243,6 +235,12 @@ namespace VIZ.H2V.Module
/// <returns>是否成功</returns>
public override bool Apply()
{
INDIViewService service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(this.ViewKey);
if (service == null)
return false;
service.AlgorithmConfig = this.Config;
return true;
}
}
......
......@@ -143,12 +143,7 @@ namespace VIZ.H2V.Module
this.KeepPrevFrame = config.KeepPrevFrame;
// 场景信息
AlgorithmStrategy strategy = ApplicationDomainEx.CsvContext.AlgorithmStrategys.FirstOrDefault(p => p.ID == (int)this.StrategyType);
if (strategy == null)
return;
this.Scences = strategy.Scenes?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)?.ToList();
this.SelectedScence = (this.Scences?.Contains(this.Config.Scene) == true) ? this.Config.Scene : this.Scences?.FirstOrDefault();
this.SelectedBorderScence = this.BorderScences?.FirstOrDefault(p => p.Key == this.Config.BorderScene) ?? this.BorderScences?.FirstOrDefault();
}
/// <summary>
......@@ -187,7 +182,7 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
if (this.SelectedBorderScence.Key != this.Config.BorderScene)
return true;
return false;
......@@ -202,9 +197,6 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
return true;
return false;
}
......@@ -229,7 +221,7 @@ namespace VIZ.H2V.Module
this.Config.NoBallAutoChangeToPerson = this.NoBallAutoChangeToPerson;
this.Config.SmoothCoeff = this.SmoothCoeff;
this.Config.KeepPrevFrame = this.KeepPrevFrame;
this.Config.Scene = this.SelectedScence;
this.Config.BorderScene = this.SelectedBorderScence.Key;
ApplicationDomainEx.LiteDbContext.AlgorithmNear.Upsert(this.Config);
......@@ -243,6 +235,12 @@ namespace VIZ.H2V.Module
/// <returns>是否成功</returns>
public override bool Apply()
{
INDIViewService service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(this.ViewKey);
if (service == null)
return false;
service.AlgorithmConfig = this.Config;
return true;
}
}
......
......@@ -90,30 +90,30 @@ namespace VIZ.H2V.Module
#endregion
#region Scences -- 场景信息集合
#region BorderScences -- 边线场景集合
private List<string> scence;
private List<AlgorithmBorderScenceModel> borderScences;
/// <summary>
/// 场景信息集合
/// 边线场景集合
/// </summary>
public List<string> Scences
public List<AlgorithmBorderScenceModel> BorderScences
{
get { return scence; }
set { scence = value; this.RaisePropertyChanged(nameof(Scences)); }
get { return borderScences; }
set { borderScences = value; this.RaisePropertyChanged(nameof(BorderScences)); }
}
#endregion
#region SelectedScence -- 选中的场景
#region SelectedBorderScence -- 选中的边线场景
private string selectedScence;
private AlgorithmBorderScenceModel selectedBorderScence;
/// <summary>
/// 选中的场景
/// 选中的边线场景
/// </summary>
public string SelectedScence
public AlgorithmBorderScenceModel SelectedBorderScence
{
get { return selectedScence; }
set { selectedScence = value; this.RaisePropertyChanged(nameof(SelectedScence)); }
get { return selectedBorderScence; }
set { selectedBorderScence = value; this.RaisePropertyChanged(nameof(SelectedBorderScence)); }
}
#endregion
......@@ -193,6 +193,24 @@ namespace VIZ.H2V.Module
{
this.SelectedGpuInfo = info.GpuInfos[this.ViewConfig.GPU];
}
// 边线场景
if (ApplicationDomainEx.CsvContext.AlgorithmBorderScenes == null || ApplicationDomainEx.CsvContext.AlgorithmBorderScenes.Count == 0)
return;
List<AlgorithmBorderScenceModel> borderScences = new List<AlgorithmBorderScenceModel>();
foreach (AlgorithmBorderScene scene in ApplicationDomainEx.CsvContext.AlgorithmBorderScenes)
{
AlgorithmBorderScenceModel model = new AlgorithmBorderScenceModel();
model.ID = scene.ID;
model.Key = scene.Key;
model.DisplayName = scene.DisplayName;
borderScences.Add(model);
}
this.BorderScences = borderScences;
}
#endregion
......
......@@ -42,12 +42,7 @@ namespace VIZ.H2V.Module
this.KeepPrevFrame = config.KeepPrevFrame;
// 场景信息
AlgorithmStrategy strategy = ApplicationDomainEx.CsvContext.AlgorithmStrategys.FirstOrDefault(p => p.ID == (int)this.StrategyType);
if (strategy == null)
return;
this.Scences = strategy.Scenes?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)?.ToList();
this.SelectedScence = (this.Scences?.Contains(this.Config.Scene) == true) ? this.Config.Scene : this.Scences?.FirstOrDefault();
this.SelectedBorderScence = this.BorderScences?.FirstOrDefault(p => p.Key == this.Config.BorderScene) ?? this.BorderScences?.FirstOrDefault();
}
/// <summary>
......@@ -68,7 +63,7 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
if (this.SelectedBorderScence.Key != this.Config.BorderScene)
return true;
return false;
......@@ -83,9 +78,6 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
return true;
return false;
}
......@@ -97,7 +89,7 @@ namespace VIZ.H2V.Module
// 保存值
this.Config.SmoothCoeff = this.SmoothCoeff;
this.Config.KeepPrevFrame = this.KeepPrevFrame;
this.Config.Scene = this.SelectedScence;
this.Config.BorderScene = this.SelectedBorderScence.Key;
this.ViewConfig.GPU = this.SelectedGpuInfo?.Physics ?? 0;
ApplicationDomainEx.LiteDbContext.AlgorithmSingle.Upsert(this.Config);
......@@ -112,6 +104,12 @@ namespace VIZ.H2V.Module
/// <returns>是否成功</returns>
public override bool Apply()
{
INDIViewService service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(this.ViewKey);
if (service == null)
return false;
service.AlgorithmConfig = this.Config;
return true;
}
}
......
......@@ -141,12 +141,7 @@ namespace VIZ.H2V.Module
this.KeepPrevFrame = config.KeepPrevFrame;
// 场景信息
AlgorithmStrategy strategy = ApplicationDomainEx.CsvContext.AlgorithmStrategys.FirstOrDefault(p => p.ID == (int)this.StrategyType);
if (strategy == null)
return;
this.Scences = strategy.Scenes?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)?.ToList();
this.SelectedScence = (this.Scences?.Contains(this.Config.Scene) == true) ? this.Config.Scene : this.Scences?.FirstOrDefault();
this.SelectedBorderScence = this.BorderScences?.FirstOrDefault(p => p.Key == this.Config.BorderScene) ?? this.BorderScences?.FirstOrDefault();
}
/// <summary>
......@@ -185,7 +180,7 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
if (this.SelectedBorderScence.Key != this.Config.BorderScene)
return true;
return false;
......@@ -200,9 +195,6 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
return true;
return false;
}
......@@ -227,7 +219,7 @@ namespace VIZ.H2V.Module
this.Config.NoBallAutoChangeToPerson = this.NoBallAutoChangeToPerson;
this.Config.SmoothCoeff = this.SmoothCoeff;
this.Config.KeepPrevFrame = this.KeepPrevFrame;
this.Config.Scene = this.SelectedScence;
this.Config.BorderScene = this.SelectedBorderScence.Key;
this.ViewConfig.GPU = this.SelectedGpuInfo?.Physics ?? 0;
ApplicationDomainEx.LiteDbContext.AlgorithmSixteen.Upsert(this.Config);
......@@ -243,6 +235,12 @@ namespace VIZ.H2V.Module
/// <returns>是否成功</returns>
public override bool Apply()
{
INDIViewService service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(this.ViewKey);
if (service == null)
return false;
service.AlgorithmConfig = this.Config;
return true;
}
}
......
......@@ -141,12 +141,7 @@ namespace VIZ.H2V.Module
this.KeepPrevFrame = config.KeepPrevFrame;
// 场景信息
AlgorithmStrategy strategy = ApplicationDomainEx.CsvContext.AlgorithmStrategys.FirstOrDefault(p => p.ID == (int)this.StrategyType);
if (strategy == null)
return;
this.Scences = strategy.Scenes?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)?.ToList();
this.SelectedScence = (this.Scences?.Contains(this.Config.Scene) == true) ? this.Config.Scene : this.Scences?.FirstOrDefault();
this.SelectedBorderScence = this.BorderScences?.FirstOrDefault(p => p.Key == this.Config.BorderScene) ?? this.BorderScences?.FirstOrDefault();
}
/// <summary>
......@@ -185,7 +180,7 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
if (this.SelectedBorderScence.Key != this.Config.BorderScene)
return true;
return false;
......@@ -200,9 +195,6 @@ namespace VIZ.H2V.Module
if (this.SelectedGpuInfo.Physics != this.ViewConfig.GPU)
return true;
if (this.SelectedScence != this.Config.Scene)
return true;
return false;
}
......@@ -227,7 +219,7 @@ namespace VIZ.H2V.Module
this.Config.NoBallAutoChangeToPerson = this.NoBallAutoChangeToPerson;
this.Config.SmoothCoeff = this.SmoothCoeff;
this.Config.KeepPrevFrame = this.KeepPrevFrame;
this.Config.Scene = this.SelectedScence;
this.Config.BorderScene = this.SelectedBorderScence.Key;
this.ViewConfig.GPU = this.SelectedGpuInfo?.Physics ?? 0;
ApplicationDomainEx.LiteDbContext.AlgorithmTactics.Upsert(this.Config);
......@@ -243,6 +235,12 @@ namespace VIZ.H2V.Module
/// <returns>是否成功</returns>
public override bool Apply()
{
INDIViewService service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(this.ViewKey);
if (service == null)
return false;
service.AlgorithmConfig = this.Config;
return true;
}
}
......
......@@ -134,7 +134,8 @@ namespace VIZ.H2V.Module
if (manager == null)
return;
AlgorithmSender.CenterMode(manager, this.Support.ID, this.Support.ViewConfig.IsSendToCrop);
// TODO: 平滑系数读取
AlgorithmSender.CenterMode(manager, this.Support.ID, this.Support.ViewConfig.IsSendToCrop, this.Support.AlgorithmConfig.SmoothCoeff);
}
/// <summary>
......@@ -151,7 +152,8 @@ namespace VIZ.H2V.Module
List<int> roi = this.Support.GetManulRoi();
AlgorithmSender.ManualMode(manager, this.Support.ID, this.Support.ViewConfig.IsSendToCrop, roi);
// TODO: 平滑系数读取
AlgorithmSender.ManualMode(manager, this.Support.ID, this.Support.ViewConfig.IsSendToCrop, roi, this.Support.AlgorithmConfig.SmoothCoeff);
}
/// <summary>
......@@ -353,9 +355,6 @@ namespace VIZ.H2V.Module
return false;
}
// 获取配置
AlgorithmBase config = this.GetConfig();
// 端口
int port = this.Support.ProcessModel.Port;
// NDI流名称
......@@ -379,7 +378,7 @@ namespace VIZ.H2V.Module
Process proc = new Process();
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.FileName = ALGORITHM_PYTHON_PATH;
proc.StartInfo.Arguments = $"\"{fullPath}\" --port=\"{port}\" --ndi_name=\"{ndi_name}\" --id=\"{id}\" --device=\"{device}\" --vis_port=\"{CLIENT_PORT}\" --scenes=\"{config.Scene ?? string.Empty}\"";
proc.StartInfo.Arguments = $"\"{fullPath}\" --port=\"{port}\" --ndi_name=\"{ndi_name}\" --id=\"{id}\" --device=\"{device}\" --vis_port=\"{CLIENT_PORT}\"";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
if (!proc.Start())
......
......@@ -61,8 +61,8 @@ namespace VIZ.H2V.Module
/// <summary>
/// 边线检测
/// </summary>
/// <param name="boarderpoint">边线检测点</param>
void BorderPoint(AlgorithmInfo_borderpoint boarderpoint);
/// <param name="borderpoint">边线检测点</param>
void BorderPoint(AlgorithmInfo_borderpoint borderpoint);
/// <summary>
/// 切换至无模式
......
......@@ -35,6 +35,11 @@ namespace VIZ.H2V.Module
NdiViewConfig ViewConfig { get; }
/// <summary>
/// 算法配置
/// </summary>
AlgorithmBase AlgorithmConfig { get; }
/// <summary>
/// 显示名称
/// </summary>
string DisplayName { get; }
......
......@@ -82,8 +82,8 @@ namespace VIZ.H2V.Module
/// <summary>
/// 边线检测校准
/// </summary>
/// <param name="boarderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint boarderpoint)
/// <param name="borderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint borderpoint)
{
}
......@@ -118,6 +118,7 @@ namespace VIZ.H2V.Module
package.weight_conf = config.ConfidenceWeight / 100d;
package.weight_distance = config.PositionToCenterWeight / 100d;
package.auto_follow_human = config.NoBallAutoChangeToPerson ? 1 : 0;
package.border_scene = config.BorderScene;
return package;
}
......
......@@ -82,10 +82,10 @@ namespace VIZ.H2V.Module
/// <summary>
/// 边线检测校准
/// </summary>
/// <param name="boarderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint boarderpoint)
/// <param name="borderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint borderpoint)
{
if (boarderpoint == null)
if (borderpoint == null)
return;
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(this.Support.ViewKey);
......@@ -95,7 +95,7 @@ namespace VIZ.H2V.Module
option.enable_sendto_crop = this.Support.ViewConfig.IsSendToCrop;
option.borderpoint = new AlgorithmInfo_borderpoint();
AlgorithmSender.AutoMode(manager, this.BuildPackage(AlgorithmAutoModeCmd.set_params, boarderpoint), option);
AlgorithmSender.AutoMode(manager, this.BuildPackage(AlgorithmAutoModeCmd.borderline_correction, borderpoint), option);
}
/// <summary>
......@@ -130,6 +130,7 @@ namespace VIZ.H2V.Module
package.weight_distance = config.PositionToCenterWeight / 100d;
package.auto_follow_human = config.NoBallAutoChangeToPerson ? 1 : 0;
package.borderpoint = boarderpoint;
package.border_scene = config.BorderScene;
return package;
}
......
......@@ -99,8 +99,8 @@ namespace VIZ.H2V.Module
/// <summary>
/// 边线检测校准
/// </summary>
/// <param name="boarderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint boarderpoint)
/// <param name="borderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint borderpoint)
{
}
......@@ -131,6 +131,7 @@ namespace VIZ.H2V.Module
package.smooth = config.SmoothCoeff;
package.max_fixed_frames = config.KeepPrevFrame;
package.bbox = box == null ? null : new List<int> { (int)box.SrcRect.Left, (int)box.SrcRect.Top, (int)box.SrcRect.Right, (int)box.SrcRect.Bottom };
package.border_scene = config.BorderScene;
return package;
}
......
......@@ -82,10 +82,10 @@ namespace VIZ.H2V.Module
/// <summary>
/// 边线检测校准
/// </summary>
/// <param name="boarderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint boarderpoint)
/// <param name="borderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint borderpoint)
{
if (boarderpoint == null)
if (borderpoint == null)
return;
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(this.Support.ViewKey);
......@@ -95,7 +95,7 @@ namespace VIZ.H2V.Module
option.enable_sendto_crop = this.Support.ViewConfig.IsSendToCrop;
option.borderpoint = new AlgorithmInfo_borderpoint();
AlgorithmSender.AutoMode(manager, this.BuildPackage(AlgorithmAutoModeCmd.set_params, boarderpoint), option);
AlgorithmSender.AutoMode(manager, this.BuildPackage(AlgorithmAutoModeCmd.borderline_correction, borderpoint), option);
}
/// <summary>
......@@ -130,6 +130,7 @@ namespace VIZ.H2V.Module
package.weight_distance = config.PositionToCenterWeight / 100d;
package.auto_follow_human = config.NoBallAutoChangeToPerson ? 1 : 0;
package.borderpoint = boarderpoint;
package.border_scene = config.BorderScene;
return package;
}
......
......@@ -82,10 +82,10 @@ namespace VIZ.H2V.Module
/// <summary>
/// 边线检测校准
/// </summary>
/// <param name="boarderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint boarderpoint)
/// <param name="borderpoint">边线检测校准点</param>
public override void BorderPoint(AlgorithmInfo_borderpoint borderpoint)
{
if (boarderpoint == null)
if (borderpoint == null)
return;
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(this.Support.ViewKey);
......@@ -95,7 +95,7 @@ namespace VIZ.H2V.Module
option.enable_sendto_crop = this.Support.ViewConfig.IsSendToCrop;
option.borderpoint = new AlgorithmInfo_borderpoint();
AlgorithmSender.AutoMode(manager, this.BuildPackage(AlgorithmAutoModeCmd.set_params, boarderpoint), option);
AlgorithmSender.AutoMode(manager, this.BuildPackage(AlgorithmAutoModeCmd.borderline_correction, borderpoint), option);
}
/// <summary>
......@@ -130,6 +130,7 @@ namespace VIZ.H2V.Module
package.weight_distance = config.PositionToCenterWeight / 100d;
package.auto_follow_human = config.NoBallAutoChangeToPerson ? 1 : 0;
package.borderpoint = boarderpoint;
package.border_scene = config.BorderScene;
return package;
}
......
......@@ -45,6 +45,11 @@ namespace VIZ.H2V.Module
NdiViewConfig ViewConfig { get; }
/// <summary>
/// 算法配置
/// </summary>
AlgorithmBase AlgorithmConfig { get; set; }
/// <summary>
/// NDI视图状态
/// </summary>
NDIViewStatus ViewStatus { get; set; }
......
......@@ -44,8 +44,8 @@ namespace VIZ.H2V.Module
// 视图键
this.ViewKey = view.NDIKey;
// 初始化视图配置
this.Loaded_ViewConfig();
// 初始化配置
this.Loaded_Config();
// 初始化属性
this.Loaded_Property();
......@@ -73,13 +73,16 @@ namespace VIZ.H2V.Module
}
/// <summary>
/// 初始化视图配置
/// 初始化配置
/// </summary>
private void Loaded_ViewConfig()
private void Loaded_Config()
{
// 视图配置
NdiViewConfig viewConfig = ApplicationDomainEx.LiteDbContext.ViewConfig.FindOne(p => p.ViewKey == this.ViewKey);
this.ViewConfig = viewConfig;
// 算法配置
this.AlgorithmConfig = this.AlgorithmControllerDic[this.ViewConfig.StrategyType].GetConfig();
}
/// <summary>
......@@ -171,26 +174,26 @@ namespace VIZ.H2V.Module
if (!this.FootballFieldPanelModel.HasSelected())
return;
AlgorithmInfo_borderpoint boarderpoint = new AlgorithmInfo_borderpoint();
AlgorithmInfo_borderpoint borderpoint = new AlgorithmInfo_borderpoint();
if (this.FootballFieldPanelModel.IsTopSelected)
{
boarderpoint.up = new List<int> { (int)e.SrcPoint.X, (int)e.SrcPoint.Y };
borderpoint.up = new List<int> { (int)e.SrcPoint.X, (int)e.SrcPoint.Y };
}
else if (this.FootballFieldPanelModel.IsBottomSelected)
{
boarderpoint.down = new List<int> { (int)e.SrcPoint.X, (int)e.SrcPoint.Y };
borderpoint.down = new List<int> { (int)e.SrcPoint.X, (int)e.SrcPoint.Y };
}
else if (this.FootballFieldPanelModel.IsLeftSelected)
{
boarderpoint.left = new List<int> { (int)e.SrcPoint.X, (int)e.SrcPoint.Y };
borderpoint.left = new List<int> { (int)e.SrcPoint.X, (int)e.SrcPoint.Y };
}
else if (this.FootballFieldPanelModel.IsRightSelected)
{
boarderpoint.right = new List<int> { (int)e.SrcPoint.X, (int)e.SrcPoint.Y };
borderpoint.right = new List<int> { (int)e.SrcPoint.X, (int)e.SrcPoint.Y };
}
this.AlgorithmControllerDic[this.StrategyType].BorderPoint(boarderpoint);
this.AlgorithmControllerDic[this.StrategyType].BorderPoint(borderpoint);
// ====================================================================================
// DEBUG
......
......@@ -164,7 +164,8 @@ namespace VIZ.H2V.Module
if (manager == null)
return;
AlgorithmSender.ManualMode(manager, this.ID, this.ViewConfig.IsSendToCrop, this.GetManulRoi());
// TODO: 平滑系数读取
AlgorithmSender.ManualMode(manager, this.ID, this.ViewConfig.IsSendToCrop, this.GetManulRoi(), 0.02);
// 在需要发送裁切框时
if (this.viewConfig.IsSendToCrop)
......
......@@ -136,6 +136,20 @@ namespace VIZ.H2V.Module
#endregion
#region AlgorithmConfig -- 算法配置
private AlgorithmBase algorithmConfig;
/// <summary>
/// 算法配置
/// </summary>
public AlgorithmBase AlgorithmConfig
{
get { return algorithmConfig; }
set { algorithmConfig = value; this.RaisePropertyChanged(nameof(AlgorithmConfig)); }
}
#endregion
#region DisplayName -- 显示名称
private string displayName;
......
......@@ -25,7 +25,7 @@ namespace VIZ.H2V.Module
/// <summary>
/// 描述
/// </summary>
public override string Detail { get; } = "应用程序启动 -- 初始化Excel";
public override string Detail { get; } = "应用程序启动 -- 初始化CSV";
/// <summary>
/// 执行启动
......@@ -35,10 +35,12 @@ namespace VIZ.H2V.Module
public override bool Setup(AppSetupContext context)
{
string algorithm_strategy_path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", "algorithm_strategy.csv");
string algorithm_border_scence_path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", "algorithm_border_scene.csv");
string clip_system_path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", "clip_system.csv");
ApplicationDomainEx.CsvContext = new CsvContext();
ApplicationDomainEx.CsvContext.LoadAlgorithmStrategys(algorithm_strategy_path);
ApplicationDomainEx.CsvContext.LoadAlgorithmBorderScenes(algorithm_border_scence_path);
ApplicationDomainEx.CsvContext.LoadClipSystems(clip_system_path);
return true;
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.H2V.Storage
{
/// <summary>
/// 算法边线场景
/// </summary>
public class AlgorithmBorderScene
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 键
/// </summary>
public string Key { get; set; }
/// <summary>
/// 显示名称
/// </summary>
public string DisplayName { get; set; }
}
}
......@@ -31,10 +31,5 @@ namespace VIZ.H2V.Storage
/// 启动路径(绝对路径 or 相对路径)
/// </summary>
public string SetupPath { get; set; }
/// <summary>
/// 场景选项集合,使用英文逗号分隔
/// </summary>
public string Scenes { get; set; }
}
}
......@@ -20,6 +20,11 @@ namespace VIZ.H2V.Storage
public List<AlgorithmStrategy> AlgorithmStrategys { get; private set; }
/// <summary>
/// 边线场景
/// </summary>
public List<AlgorithmBorderScene> AlgorithmBorderScenes { get; private set; }
/// <summary>
/// 裁切系统
/// </summary>
public List<ClipSystem> ClipSystems { get; private set; }
......@@ -30,7 +35,7 @@ namespace VIZ.H2V.Storage
/// <param name="path">文件路径</param>
public void LoadAlgorithmStrategys(string path)
{
using (StreamReader sr = new StreamReader(path, Encoding.UTF8))
using (StreamReader sr = new StreamReader(path, Encoding.Default))
using (CsvReader reader = new CsvReader(sr, CultureInfo.InvariantCulture))
{
this.AlgorithmStrategys = reader.GetRecords<AlgorithmStrategy>()?.ToList();
......@@ -38,12 +43,25 @@ namespace VIZ.H2V.Storage
}
/// <summary>
/// 加载边线场景
/// </summary>
/// <param name="path">文件路径</param>
public void LoadAlgorithmBorderScenes(string path)
{
using (StreamReader sr = new StreamReader(path, Encoding.Default))
using (CsvReader reader = new CsvReader(sr, CultureInfo.InvariantCulture))
{
this.AlgorithmBorderScenes = reader.GetRecords<AlgorithmBorderScene>()?.ToList();
}
}
/// <summary>
/// 加载裁切系统配置
/// </summary>
/// <param name="path">文件路径</param>
public void LoadClipSystems(string path)
{
using (StreamReader sr = new StreamReader(path, Encoding.UTF8))
using (StreamReader sr = new StreamReader(path, Encoding.Default))
using (CsvReader reader = new CsvReader(sr, CultureInfo.InvariantCulture))
{
this.ClipSystems = reader.GetRecords<ClipSystem>()?.ToList();
......
......@@ -12,6 +12,11 @@ namespace VIZ.H2V.Storage
public class AlgorithmCableway : AlgorithmBase
{
/// <summary>
/// 边线检测场景
/// </summary>
public override string BorderScene { get; set; } = AlgorithmBorderSceneType._fly_cat;
/// <summary>
/// 人物面积占比
/// </summary>
public double PersonAreaProportion { get; set; } = 9;
......
......@@ -12,6 +12,11 @@ namespace VIZ.H2V.Storage
public class AlgorithmNear : AlgorithmBase
{
/// <summary>
/// 边线检测场景
/// </summary>
public override string BorderScene { get; set; } = AlgorithmBorderSceneType._close_up;
/// <summary>
/// 人物面积占比
/// </summary>
public double PersonAreaProportion { get; set; } = 9;
......
......@@ -11,5 +11,10 @@ namespace VIZ.H2V.Storage
/// </summary>
public class AlgorithmSingle : AlgorithmBase
{
/// <summary>
/// 边线检测场景
/// </summary>
public override string BorderScene { get; set; } = AlgorithmBorderSceneType._single_person;
}
}
......@@ -12,6 +12,11 @@ namespace VIZ.H2V.Storage
public class AlgorithmSixteen : AlgorithmBase
{
/// <summary>
/// 边线检测场景
/// </summary>
public override string BorderScene { get; set; } = AlgorithmBorderSceneType._16m_left;
/// <summary>
/// 人物面积占比
/// </summary>
public double PersonAreaProportion { get; set; } = 9;
......
......@@ -12,6 +12,11 @@ namespace VIZ.H2V.Storage
public class AlgorithmTactics : AlgorithmBase
{
/// <summary>
/// 边线检测场景
/// </summary>
public override string BorderScene { get; set; } = AlgorithmBorderSceneType._tactical;
/// <summary>
/// 人物面积占比
/// </summary>
public double PersonAreaProportion { get; set; } = 9;
......
......@@ -35,8 +35,8 @@ namespace VIZ.H2V.Storage
public int KeepPrevFrame { get; set; } = 75;
/// <summary>
/// 场景
/// 边线检测场景
/// </summary>
public string Scene { get; set; }
public virtual string BorderScene { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.H2V.Storage
{
/// <summary>
/// 算法边线检测场景类型
/// </summary>
public static class AlgorithmBorderSceneType
{
/// <summary>
/// 单人
/// </summary>
public const string _single_person = "single_person";
/// <summary>
/// 近景
/// </summary>
public const string _close_up = "close_up";
/// <summary>
/// 16米左
/// </summary>
public const string _16m_left = "16m_left";
/// <summary>
/// 16米右
/// </summary>
public const string _16m_right = "16m_right";
/// <summary>
/// 战术
/// </summary>
public const string _tactical = "tactical";
/// <summary>
/// 索道
/// </summary>
public const string _fly_cat = "fly_cat";
}
}
......@@ -33,6 +33,11 @@ namespace VIZ.H2V.Storage
public string ClipManualColor { get; set; } = "#ffd9001b";
/// <summary>
/// 边线颜色
/// </summary>
public string BorderLineColor { get; set; } = "#44FF000000";
/// <summary>
/// 手动裁切是否使用平滑
/// </summary>
public bool IsManualUseSmooth { get; set; } = true;
......
......@@ -111,12 +111,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CSV\Algorithm\AlgorithmBorderScene.cs" />
<Compile Include="CSV\Algorithm\AlgorithmStrategy.cs" />
<Compile Include="CSV\Clip\ClipSystem.cs" />
<Compile Include="CSV\CsvContext.cs" />
<Compile Include="Init\Config\AlgorithmConfig.cs" />
<Compile Include="Init\Config\UdpConfig.cs" />
<Compile Include="LiteDB\Algorithm\AlgorithmBase.cs" />
<Compile Include="LiteDB\Algorithm\AlgorithmBorderSceneType.cs" />
<Compile Include="LiteDB\Algorithm\AlgorithmStrategyMode.cs" />
<Compile Include="LiteDB\Algorithm\AlgorithmStrategyType.cs" />
<Compile Include="LiteDB\Algorithm\Algorithm\AlgorithmNear.cs" />
......
......@@ -146,6 +146,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="config\algorithm_border_scene.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config\algorithm_strategy.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
ID,Key,DisplayName
1,single_person,单人
2,close_up,近景
3,16m_left,16米左
4,16m_right,16米右
5,tactical,战术
6,fly_cat,索道
ID,Name,DisplayName,SetupPath,Scenes
1,单人机位,单人机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,single_person
2,近景机位,近景机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,close_up
3,16米机位,16米机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,"16m_left,16m_right"
4,战术机位,战术机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,tactical
5,索道机位,索道机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,fly_cat
1,单人机位,单人机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,single_person
2,近景机位,近景机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,close_up
3,16米机位,16米机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,"16m_left,16m_right"
4,战术机位,战术机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,tactical
5,索道机位,索道机位,E:\Projects\VIZ.H2V\VIZ.H2V.UdpTestTool\bin\x64\Debug\VIZ.H2V.UdpTestTool.exe,fly_cat
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment