Commit cb9d3722 by liulongfei

1. 添加面积百分比校准功能

parent bb3b8139
...@@ -15,5 +15,15 @@ namespace VIZ.H2V.Connection ...@@ -15,5 +15,15 @@ namespace VIZ.H2V.Connection
/// 跟踪框坐标(左上角x,y,右下角x,y) /// 跟踪框坐标(左上角x,y,右下角x,y)
/// </summary> /// </summary>
public List<int> bbox { get; set; } public List<int> bbox { get; set; }
/// <summary>
/// 面积校准比例
/// </summary>
public double area_correction_ratio { get; set; }
/// <summary>
/// 是否启用面积校准
/// </summary>
public int area_correction_on { get; set; }
} }
} }
...@@ -110,4 +110,36 @@ ...@@ -110,4 +110,36 @@
</Setter> </Setter>
</Style> </Style>
<Style x:Key="CheckBox_IsAreaCorrectionEnabled" TargetType="CheckBox">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Width" Value="32"></Setter>
<Setter Property="Height" Value="32"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid x:Name="border" Background="Transparent" UseLayoutRounding="True">
<Image x:Name="img" Visibility="Visible" Width="24" Height="24"
VerticalAlignment="Center" HorizontalAlignment="Center"
Source="/VIZ.H2V.Module.Resource;component/Icons/area_24x24.png"></Image>
<Image x:Name="img_over" Visibility="Collapsed" Width="24" Height="24"
VerticalAlignment="Center" HorizontalAlignment="Center"
Source="/VIZ.H2V.Module.Resource;component/Icons/area_over_24x24.png"></Image>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="img" Property="Visibility" Value="Collapsed"></Setter>
<Setter TargetName="img_over" Property="Visibility" Value="Visible"></Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="border" Property="Opacity" Value="0.7"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#22ffffff"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary> </ResourceDictionary>
\ No newline at end of file
...@@ -104,5 +104,23 @@ ...@@ -104,5 +104,23 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style TargetType="RadioButton" x:Key="RadioButton_NdiView_None">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
></ContentPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.7"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary> </ResourceDictionary>
\ No newline at end of file
...@@ -193,5 +193,9 @@ ...@@ -193,5 +193,9 @@
<Resource Include="Icons\footbal_field_24x24.png" /> <Resource Include="Icons\footbal_field_24x24.png" />
<Resource Include="Icons\footbal_field_over_24x24.png" /> <Resource Include="Icons\footbal_field_over_24x24.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Icons\area_24x24.png" />
<Resource Include="Icons\area_over_24x24.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
<RowDefinition Height="60"></RowDefinition> <RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition> <RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition> <RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 裁切框移动 --> <!-- 裁切框移动 -->
...@@ -134,6 +135,19 @@ ...@@ -134,6 +135,19 @@
</ComboBox> </ComboBox>
</Grid> </Grid>
<!-- 单人机位面积校准 -->
<Grid Grid.Row="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="380"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="40"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="跟踪框面积占比小于x%时自动校准" Foreground="White" FontSize="18" VerticalAlignment="Center"></TextBlock>
<fcommon:NumberBox Grid.Column="1" MinValue="0" MaxValue="100" Interval="0.01" Height="40"
Value="{Binding Path=AreaCorrectionRatio,Mode=TwoWay}"></fcommon:NumberBox>
<TextBlock Text="%" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Column="2"
Margin="10,0,0,0"></TextBlock>
</Grid>
</Grid> </Grid>
</Border> </Border>
</UserControl> </UserControl>
...@@ -24,6 +24,24 @@ namespace VIZ.H2V.Module ...@@ -24,6 +24,24 @@ namespace VIZ.H2V.Module
private AlgorithmSingle Config; private AlgorithmSingle Config;
// ====================================================================================== // ======================================================================================
// === Property ===
// ======================================================================================
#region AreaCorrectionRatio -- 单人机位面积校准
private double areaCorrectionRatio;
/// <summary>
/// 单人机位面积校准
/// </summary>
public double AreaCorrectionRatio
{
get { return areaCorrectionRatio; }
set { areaCorrectionRatio = value; this.RaisePropertyChanged(nameof(AreaCorrectionRatio)); }
}
#endregion
// ======================================================================================
// === Override === // === Override ===
// ====================================================================================== // ======================================================================================
...@@ -40,6 +58,7 @@ namespace VIZ.H2V.Module ...@@ -40,6 +58,7 @@ namespace VIZ.H2V.Module
this.SmoothCoeff = config.SmoothCoeff; this.SmoothCoeff = config.SmoothCoeff;
this.KeepPrevFrame = config.KeepPrevFrame; this.KeepPrevFrame = config.KeepPrevFrame;
this.AreaCorrectionRatio = config.AreaCorrectionRatio;
// 场景信息 // 场景信息
this.SelectedBorderScence = this.BorderScences?.FirstOrDefault(p => p.Key == this.Config.BorderScene) ?? this.BorderScences?.FirstOrDefault(); this.SelectedBorderScence = this.BorderScences?.FirstOrDefault(p => p.Key == this.Config.BorderScene) ?? this.BorderScences?.FirstOrDefault();
...@@ -66,6 +85,9 @@ namespace VIZ.H2V.Module ...@@ -66,6 +85,9 @@ namespace VIZ.H2V.Module
if (this.SelectedBorderScence.Key != this.Config.BorderScene) if (this.SelectedBorderScence.Key != this.Config.BorderScene)
return true; return true;
if (this.AreaCorrectionRatio != this.Config.AreaCorrectionRatio)
return true;
return false; return false;
} }
...@@ -90,6 +112,7 @@ namespace VIZ.H2V.Module ...@@ -90,6 +112,7 @@ namespace VIZ.H2V.Module
this.Config.SmoothCoeff = this.SmoothCoeff; this.Config.SmoothCoeff = this.SmoothCoeff;
this.Config.KeepPrevFrame = this.KeepPrevFrame; this.Config.KeepPrevFrame = this.KeepPrevFrame;
this.Config.BorderScene = this.SelectedBorderScence.Key; this.Config.BorderScene = this.SelectedBorderScence.Key;
this.Config.AreaCorrectionRatio = this.AreaCorrectionRatio;
this.ViewConfig.GPU = this.SelectedGpuInfo?.Physics ?? 0; this.ViewConfig.GPU = this.SelectedGpuInfo?.Physics ?? 0;
ApplicationDomainEx.LiteDbContext.AlgorithmSingle.Upsert(this.Config); ApplicationDomainEx.LiteDbContext.AlgorithmSingle.Upsert(this.Config);
......
...@@ -179,6 +179,8 @@ namespace VIZ.H2V.Module ...@@ -179,6 +179,8 @@ namespace VIZ.H2V.Module
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.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; package.border_scene = config.BorderScene;
package.border_on = config.IsBorderEnabled ? 1 : 0; package.border_on = config.IsBorderEnabled ? 1 : 0;
package.area_correction_ratio = config.AreaCorrectionRatio;
package.area_correction_on = config.IsAreaCorrectionEnabled ? 1 : 0;
return package; return package;
} }
......
...@@ -39,6 +39,11 @@ ...@@ -39,6 +39,11 @@
StrategyModeListString="auto_mode" StrategyModeListString="auto_mode"
StrategyTypeListString="Single"> StrategyTypeListString="Single">
</resource:NDIViewProperty2BoolConverter> </resource:NDIViewProperty2BoolConverter>
<resource:NDIViewProperty2BoolConverter x:Key="NDIViewProperty2BoolConverter_IsAreaCorrectionEnabled"
ViewStatusListString="Detect,CropRoi"
StrategyModeListString="auto_mode"
StrategyTypeListString="Single">
</resource:NDIViewProperty2BoolConverter>
<!-- 边线选择面板 --> <!-- 边线选择面板 -->
<resource:NDIViewProperty2VisibilityConverter x:Key="NDIViewProperty2VisibilityConverter_FootballFieldPanel" <resource:NDIViewProperty2VisibilityConverter x:Key="NDIViewProperty2VisibilityConverter_FootballFieldPanel"
ViewStatusListString="Detect,CropRoi" ViewStatusListString="Detect,CropRoi"
...@@ -175,7 +180,7 @@ ...@@ -175,7 +180,7 @@
<RowDefinition Height="auto"></RowDefinition> <RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<RadioButton Content="手动校准" Foreground="White" FontSize="20" <!--<RadioButton Content="手动校准" Foreground="White" FontSize="20"
Style="{StaticResource RadioButton_NdiView_Tool}" Style="{StaticResource RadioButton_NdiView_Tool}"
IsChecked="{Binding Path=ToolPartViewModel.IsManualCorrectionChecked,Mode=TwoWay}" IsChecked="{Binding Path=ToolPartViewModel.IsManualCorrectionChecked,Mode=TwoWay}"
GroupName="{Binding Path=ViewKey,Converter={StaticResource StringAppendConverter}, ConverterParameter=Tool}" GroupName="{Binding Path=ViewKey,Converter={StaticResource StringAppendConverter}, ConverterParameter=Tool}"
...@@ -187,12 +192,12 @@ ...@@ -187,12 +192,12 @@
<Binding Path="DataContext.StrategyType" ElementName="uc"></Binding> <Binding Path="DataContext.StrategyType" ElementName="uc"></Binding>
</MultiBinding> </MultiBinding>
</RadioButton.Visibility> </RadioButton.Visibility>
</RadioButton> </RadioButton>-->
<!-- 近景机位 & 16米机位 & 战术机位 ===== 边线检测选择面板 --> <!-- 近景机位 & 16米机位 & 战术机位 ===== 边线检测选择面板 -->
<Border Grid.Row="1" <Border Grid.Row="1"
Visibility="{Binding Path=AlgorithmConfig.IsShowBorder,Mode=OneWay,Converter={StaticResource Bool2VisibilityConverter}}"> Visibility="{Binding Path=AlgorithmConfig.IsShowBorder,Mode=OneWay,Converter={StaticResource Bool2VisibilityConverter}}">
<RadioButton Style="{StaticResource RadioButton_NdiView_Tool}" <RadioButton Style="{StaticResource RadioButton_NdiView_None}"
Height="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldHeightConverter}}" Height="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldHeightConverter}}"
IsChecked="{Binding Path=ToolPartViewModel.IsSideCheckPolygonChecked,Mode=TwoWay}" IsChecked="{Binding Path=ToolPartViewModel.IsSideCheckPolygonChecked,Mode=TwoWay}"
GroupName="{Binding Path=ViewKey,Converter={StaticResource StringAppendConverter}, ConverterParameter=Tool}" GroupName="{Binding Path=ViewKey,Converter={StaticResource StringAppendConverter}, ConverterParameter=Tool}"
...@@ -219,6 +224,28 @@ ...@@ -219,6 +224,28 @@
<!-- 显示组 --> <!-- 显示组 -->
<StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,0,5" Orientation="Horizontal"> <StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,0,5" Orientation="Horizontal">
<!-- 启用面积百分比校准 -->
<!-- 仅单人机位可用 -->
<CheckBox Style="{StaticResource CheckBox_IsAreaCorrectionEnabled}" Width="32" Height="32" Margin="0,0,10,0"
ToolTip="启用面积百分比校准"
IsChecked="{Binding Path=AlgorithmConfig.IsAreaCorrectionEnabled,Mode=TwoWay}">
<CheckBox.IsEnabled>
<MultiBinding Converter="{StaticResource NDIViewProperty2BoolConverter_IsAreaCorrectionEnabled}">
<Binding Path="ViewStatus"></Binding>
<Binding Path="StrategyMode"></Binding>
<Binding Path="StrategyType"></Binding>
</MultiBinding>
</CheckBox.IsEnabled>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Checked">
<behaviors:InvokeCommandAction Command="{Binding IsAreaCorrectionEnabledChangedCommand}" />
</behaviors:EventTrigger>
<behaviors:EventTrigger EventName="Unchecked">
<behaviors:InvokeCommandAction Command="{Binding IsAreaCorrectionEnabledChangedCommand}" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
</CheckBox>
<!-- 启用边线过滤 -->
<CheckBox Style="{StaticResource CheckBox_IsBorderEnabled}" Width="32" Height="32" Margin="0,0,10,0" <CheckBox Style="{StaticResource CheckBox_IsBorderEnabled}" Width="32" Height="32" Margin="0,0,10,0"
ToolTip="启用边线过滤" ToolTip="启用边线过滤"
IsEnabled="{Binding Path=ViewStatus,Converter={StaticResource NDIViewStatus2IsEnabledConverter}}" IsEnabled="{Binding Path=ViewStatus,Converter={StaticResource NDIViewStatus2IsEnabledConverter}}"
...@@ -232,6 +259,7 @@ ...@@ -232,6 +259,7 @@
</behaviors:EventTrigger> </behaviors:EventTrigger>
</behaviors:Interaction.Triggers> </behaviors:Interaction.Triggers>
</CheckBox> </CheckBox>
<!-- 显示边线 -->
<CheckBox Style="{StaticResource CheckBox_IsBorderShow}" Width="32" Height="32" <CheckBox Style="{StaticResource CheckBox_IsBorderShow}" Width="32" Height="32"
x:Name="cb_showBorder" x:Name="cb_showBorder"
ToolTip="显示边线" ToolTip="显示边线"
......
...@@ -104,7 +104,7 @@ namespace VIZ.H2V.Module ...@@ -104,7 +104,7 @@ namespace VIZ.H2V.Module
this.StrategyMode = this.ViewConfig.StrategyMode; this.StrategyMode = this.ViewConfig.StrategyMode;
// 记录档期操作日志 // 记录档期操作日志
this.WriteLogOperation(); this.WriteLogOperation(this.StrategyMode);
} }
/// <summary> /// <summary>
...@@ -130,9 +130,9 @@ namespace VIZ.H2V.Module ...@@ -130,9 +130,9 @@ namespace VIZ.H2V.Module
view.video.AttachPlugin(sideCheckPolygonPlugin); view.video.AttachPlugin(sideCheckPolygonPlugin);
// 手动校准插件 // 手动校准插件
ManualCorrectionPlugin manualCorrectionPlugin = new ManualCorrectionPlugin(view.video); //ManualCorrectionPlugin manualCorrectionPlugin = new ManualCorrectionPlugin(view.video);
manualCorrectionPlugin.Click += ManualCorrectionPlugin_Click; //manualCorrectionPlugin.Click += ManualCorrectionPlugin_Click;
view.video.AttachPlugin(manualCorrectionPlugin); //view.video.AttachPlugin(manualCorrectionPlugin);
} }
/// <summary> /// <summary>
...@@ -396,5 +396,28 @@ namespace VIZ.H2V.Module ...@@ -396,5 +396,28 @@ namespace VIZ.H2V.Module
} }
#endregion #endregion
#region IsAreaCorrectionEnabledChangedCommand -- 是否启用单人机位面积百分比校准可用改变命令
/// <summary>
/// 是否启用单人机位面积百分比校准可用改变命令
/// </summary>
public VCommand IsAreaCorrectionEnabledChangedCommand { get; set; }
/// <summary>
/// 是否启用单人机位面积百分比校准可用改变
/// </summary>
private void IsAreaCorrectionEnabledChanged()
{
this.AlgorithmControllerDic[this.StrategyType].SaveConfig(this.AlgorithmConfig);
// 算法未准备完毕不需要向算法发送指令
if (!this.IsViewStatusReady())
return;
this.AlgorithmControllerDic[this.StrategyType].SetParams();
}
#endregion
} }
} }
...@@ -67,6 +67,7 @@ namespace VIZ.H2V.Module ...@@ -67,6 +67,7 @@ namespace VIZ.H2V.Module
this.StopCommand = new VCommand(this.Stop); this.StopCommand = new VCommand(this.Stop);
this.IsBorderShowChangedCommand = new VCommand(this.IsBorderShowChanged); this.IsBorderShowChangedCommand = new VCommand(this.IsBorderShowChanged);
this.IsBorderEnabledChangedCommand = new VCommand(this.IsBorderEnabledChanged); this.IsBorderEnabledChangedCommand = new VCommand(this.IsBorderEnabledChanged);
this.IsAreaCorrectionEnabledChangedCommand = new VCommand(this.IsAreaCorrectionEnabledChanged);
} }
/// <summary> /// <summary>
...@@ -128,7 +129,7 @@ namespace VIZ.H2V.Module ...@@ -128,7 +129,7 @@ namespace VIZ.H2V.Module
try try
{ {
// 记录操作日志 // 记录操作日志
this.WriteLogOperation(); this.WriteLogOperation(context.Mode);
// 停止3D鼠标更新 // 停止3D鼠标更新
this.ManualController.ClipBoxSmooth.IsEnabled = false; this.ManualController.ClipBoxSmooth.IsEnabled = false;
...@@ -355,7 +356,8 @@ namespace VIZ.H2V.Module ...@@ -355,7 +356,8 @@ namespace VIZ.H2V.Module
/// <summary> /// <summary>
/// 操作日志 /// 操作日志
/// </summary> /// </summary>
private void WriteLogOperation() /// <param name="strategyMode">当前模式</param>
private void WriteLogOperation(AlgorithmStrategyMode strategyMode)
{ {
AlgorithmStrategyMode last_mode = this.StrategyMode; AlgorithmStrategyMode last_mode = this.StrategyMode;
...@@ -373,7 +375,7 @@ namespace VIZ.H2V.Module ...@@ -373,7 +375,7 @@ namespace VIZ.H2V.Module
LogOperation log = new LogOperation(); LogOperation log = new LogOperation();
log.ViewKey = this.ViewKey; log.ViewKey = this.ViewKey;
log.StrategyType = this.StrategyType.GetDescription(); log.StrategyType = this.StrategyType.GetDescription();
log.Operation = last_mode.GetDescription(); log.Operation = strategyMode.GetDescription();
log.BeginTime = now; log.BeginTime = now;
ApplicationDomainEx.CsvContext.LogOperations.Enqueue(log); ApplicationDomainEx.CsvContext.LogOperations.Enqueue(log);
......
...@@ -14,7 +14,7 @@ namespace VIZ.H2V.Module ...@@ -14,7 +14,7 @@ namespace VIZ.H2V.Module
{ {
#region IsManualCorrectionChecked -- 手动校准是否选中 #region IsManualCorrectionChecked -- 手动校准是否选中
private bool isManualCorrectionChecked = true; private bool isManualCorrectionChecked = false;
/// <summary> /// <summary>
/// 手动校准是否选中 /// 手动校准是否选中
/// </summary> /// </summary>
...@@ -28,7 +28,7 @@ namespace VIZ.H2V.Module ...@@ -28,7 +28,7 @@ namespace VIZ.H2V.Module
#region IsSideCheckPolygonChecked -- 边线检测是否选中 #region IsSideCheckPolygonChecked -- 边线检测是否选中
private bool isSideCheckPolygonChecked; private bool isSideCheckPolygonChecked = true;
/// <summary> /// <summary>
/// 边线检测是否选中 /// 边线检测是否选中
/// </summary> /// </summary>
......
...@@ -16,5 +16,14 @@ namespace VIZ.H2V.Storage ...@@ -16,5 +16,14 @@ namespace VIZ.H2V.Storage
/// </summary> /// </summary>
public override string BorderScene { get; set; } = AlgorithmBorderSceneType._single_person; public override string BorderScene { get; set; } = AlgorithmBorderSceneType._single_person;
/// <summary>
/// 面积校准比例
/// </summary>
public double AreaCorrectionRatio { get; set; } = 0.05d;
/// <summary>
/// 是否启用面积校准
/// </summary>
public bool IsAreaCorrectionEnabled { get; set; } = true;
} }
} }
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