Commit ef52c28d by liulongfei

是否显示边线检测区域

parent b649afff
......@@ -69,6 +69,20 @@ namespace VIZ.H2V.Common
#endregion
#region IsShowBorder -- 是否显示边框
private bool isShowBorder;
/// <summary>
/// 是否显示边框
/// </summary>
public bool IsShowBorder
{
get { return isShowBorder; }
set { isShowBorder = value; this.RaisePropertyChanged(nameof(IsShowBorder)); }
}
#endregion
/// <summary>
/// 是否有选中的项
/// </summary>
......
......@@ -13,7 +13,7 @@
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="BorderBrush" Value="#aaffc000"></Setter>
<Setter TargetName="border" Property="BorderBrush" Value="#ccffc000"></Setter>
<Setter TargetName="border" Property="Background" Value="#11ffffff"></Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
......
......@@ -46,4 +46,31 @@
</Setter>
</Style>
<Style x:Key="CheckBox_Eye" TargetType="CheckBox">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Width" Value="30"></Setter>
<Setter Property="Height" Value="30"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Border x:Name="border" Background="Transparent">
<Ellipse Width="12" Height="12" x:Name="ellipse" Fill="#44ffc000"
HorizontalAlignment="Center" VerticalAlignment="Center"></Ellipse>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="ellipse" Property="Fill" Value="#aaffc000"></Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ellipse" Property="Opacity" Value="0.7"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#11ffffff"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
......@@ -62,7 +62,7 @@ namespace VIZ.H2V.Module
this.Detect();
// 清理视图控件
ClearVideoControlContext clear_context = new ClearVideoControlContext();
ClearVideoControlContext clear_context = new ClearVideoControlContext(true);
this.Support.ClearVideoControl(clear_context);
}
......
......@@ -12,18 +12,28 @@ namespace VIZ.H2V.Module
public class ClearVideoControlContext
{
/// <summary>
/// 是否清理跟踪框
/// 清理视图控件上下文
/// </summary>
public bool IsClearTrackingBox { get; set; } = true;
/// <param name="defaultValue">默认值</param>
public ClearVideoControlContext(bool defaultValue)
{
this.IsClearTrackingBox = defaultValue;
this.IsClearClipBox = defaultValue;
this.IsClearSideCheckPolygon = defaultValue;
}
/// <summary>
/// 是否清理跟踪框
/// </summary>
public bool IsClearTrackingBox { get; set; }
/// <summary>
/// 是否清理裁切框
/// </summary>
public bool IsClearClipBox { get; set; } = true;
public bool IsClearClipBox { get; set; }
/// <summary>
/// 是否清理边线检测多边形
/// </summary>
public bool IsClearSideCheckPolygon { get; set; } = true;
public bool IsClearSideCheckPolygon { get; set; }
}
}
......@@ -172,11 +172,26 @@
<fcommon:VideoControl x:Name="video"></fcommon:VideoControl>
</Border>
<!-- 显示组 -->
<StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,0,5">
<CheckBox Style="{StaticResource CheckBox_Eye}" Width="30" Height="30"
IsEnabled="{Binding Path=ViewStatus,Converter={StaticResource NDIViewStatus2IsEnabledConverter}}"
IsChecked="{Binding Path=FootballFieldPanelModel.IsShowBorder,Mode=TwoWay}">
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Unchecked">
<behaviors:InvokeCommandAction Command="{Binding ClearSideCheckPolygonCommand}" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
</CheckBox>
</StackPanel>
<!-- 设置 -->
<Button Height="40" Width="40" Grid.Column="2" Grid.Row="1" VerticalAlignment="Top"
IsEnabled="{Binding Path=ViewStatus,Converter={StaticResource NDIViewStatus2IsEnabledConverter_SettingButton}}"
Style="{StaticResource Button_Setting_Open}"
Command="{Binding Path=SettingCommand,Mode=OneWay}"
CommandParameter="{Binding ElementName=uc,Path=NDIKey,Mode=OneWay}"></Button>
<StackPanel Orientation="Vertical" VerticalAlignment="Top" Grid.Column="2" Grid.Row="1" >
<Button Height="40" Width="40" HorizontalAlignment="Center"
IsEnabled="{Binding Path=ViewStatus,Converter={StaticResource NDIViewStatus2IsEnabledConverter_SettingButton}}"
Style="{StaticResource Button_Setting_Open}"
Command="{Binding Path=SettingCommand,Mode=OneWay}"
CommandParameter="{Binding ElementName=uc,Path=NDIKey,Mode=OneWay}"></Button>
</StackPanel>
</Grid>
</UserControl>
......@@ -249,7 +249,7 @@ namespace VIZ.H2V.Module
return;
// 清理视频控件
ClearVideoControlContext clear_context = new ClearVideoControlContext();
ClearVideoControlContext clear_context = new ClearVideoControlContext(true);
this.ClearVideoControl(clear_context);
// 切换自动模式
......@@ -275,8 +275,12 @@ namespace VIZ.H2V.Module
/// </summary>
private void Restart()
{
MessageBoxExResult result = MessageBoxEx.ShowDialog("提示", "重启算法进程需要大概(1 min),是否继续?", MessageBoxExButtons.YES_CANCEL);
if (result == MessageBoxExResult.CANCEL)
return;
// 清理视频控件
ClearVideoControlContext clear_context = new ClearVideoControlContext();
ClearVideoControlContext clear_context = new ClearVideoControlContext(true);
this.ClearVideoControl(clear_context);
// 算法重启
......@@ -284,5 +288,25 @@ namespace VIZ.H2V.Module
}
#endregion
#region ClearSideCheckPolygonCommand -- 清理边线检测多边形命令
/// <summary>
/// 清理边线检测多边形命令
/// </summary>
public VCommand ClearSideCheckPolygonCommand { get; set; }
/// <summary>
/// 清理边线检测多边形
/// </summary>
private void ClearSideCheckPolygon()
{
ClearVideoControlContext clear_context = new ClearVideoControlContext(false);
clear_context.IsClearSideCheckPolygon = true;
this.ClearVideoControl(clear_context);
}
#endregion
}
}
......@@ -248,7 +248,7 @@ namespace VIZ.H2V.Module
/// <param name="view">视图</param>
private void OnAlgorithmMessage__crop_roi__borderline(AlgorithmMessage__crop_roi msg, VideoRenderInfo renderInfo, NDIView view)
{
if (msg.borderline == null)
if (msg.borderline == null || !this.FootballFieldPanelModel.IsShowBorder)
{
view.video.ClearSideCheckPolygon();
......
......@@ -58,6 +58,7 @@ namespace VIZ.H2V.Module
this.SettingCommand = new VCommand<string>(this.Setting);
this.DetectCommand = new VCommand(this.Detect);
this.RestartCommand = new VCommand(this.Restart);
this.ClearSideCheckPolygonCommand = new VCommand(this.ClearSideCheckPolygon);
}
/// <summary>
......@@ -139,7 +140,7 @@ namespace VIZ.H2V.Module
// ----------------------------------------------------------------------------------------------
// 清理视频控件
ClearVideoControlContext clear_context = new ClearVideoControlContext();
ClearVideoControlContext clear_context = new ClearVideoControlContext(true);
// 当前处于裁切状态时不需要清理裁切框
clear_context.IsClearClipBox = this.ViewStatus != NDIViewStatus.CropRoi;
this.ClearVideoControl(clear_context);
......@@ -333,7 +334,7 @@ namespace VIZ.H2V.Module
log.Operation = last_mode.GetDescription();
log.BeginTime = now;
ApplicationDomainEx.CsvContext.LogOperations.Add(log);
ApplicationDomainEx.CsvContext.LogOperations.Enqueue(log);
}
}
}
......
......@@ -76,7 +76,7 @@ namespace VIZ.H2V.Module
/// </summary>
private void WriteLogOperations()
{
ApplicationDomainEx.CsvContext.FlushLogOperations();
ApplicationDomainEx.CsvContext.FlushLogOperations(false);
}
}
}
......@@ -39,7 +39,7 @@ namespace VIZ.H2V.Storage
/// 操作日志
/// </summary>
[Csv(Scene = CsvScene.Write)]
public List<LogOperation> LogOperations { get; private set; }
public Queue<LogOperation> LogOperations { get; private set; }
/// <summary>
/// 加载算法信息
......@@ -105,23 +105,31 @@ namespace VIZ.H2V.Storage
CsvWriter writer = new CsvWriter(new StreamWriter(fileName, false, Encoding.Default), config);
writer.Context.RegisterClassMap(new LogOperationMap());
this.LogOperations = new List<LogOperation>();
this.LogOperations = new Queue<LogOperation>();
this.logOperationsWriter = writer;
}
/// <summary>
/// 输出操作日志
/// </summary>
public void FlushLogOperations()
/// <param name="writeLast">是否写入最后一个数据</param>
public void FlushLogOperations(bool writeLast)
{
if (this.logOperationsWriter == null || this.LogOperations == null || this.LogOperations.Count == 0)
return;
List<LogOperation> list = new List<LogOperation>();
lock (this.LogOperations)
{
this.logOperationsWriter.WriteRecords(this.LogOperations);
int count = writeLast ? 0 : 1;
this.LogOperations.Clear();
while (this.LogOperations.Count > count)
{
LogOperation log = this.LogOperations.Dequeue();
list.Add(log);
}
this.logOperationsWriter.WriteRecords(list);
}
}
......@@ -130,7 +138,7 @@ namespace VIZ.H2V.Storage
/// </summary>
public void CloseLogOperations()
{
this.FlushLogOperations();
this.FlushLogOperations(true);
this.logOperationsWriter?.Flush();
this.logOperationsWriter?.Dispose();
this.logOperationsWriter = null;
......
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