Commit dbbd0b98 by 鲁志-悦动

算法加个Reset功能 And Replay出入点时间戳和Index逻辑优化

parent 9dc39a29
......@@ -92,6 +92,11 @@
public const string GO_ON = "go_on";
/// <summary>
/// Reset
/// </summary>
public const string Reset = "reset";
/// <summary>
/// 落盘,开始结束时间戳
/// </summary>
public const string START_END = "start_end";
......
......@@ -15,6 +15,26 @@
/// <summary>
/// 删除位置标记
/// </summary>
Delete
Delete,
/// <summary>
/// 帧左移
/// </summary>
Left,
/// <summary>
/// 帧右移
/// </summary>
Right,
/// <summary>
/// 帧跳到入点位置
/// </summary>
Top,
/// <summary>
/// 帧跳到出点位置
/// </summary>
Bottom
}
}
......@@ -10,6 +10,10 @@
public bool IsReplayStarted { get; set; }
public bool IsStartValue { get; set; }
public bool IsEndValue { get; set; }
public int SliderValue { get; set; }
public bool IsSliderValueChanged { get; set; }
......
......@@ -547,7 +547,7 @@
<GroupBox
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.ColumnSpan="3"
Foreground="White"
Header="算法">
<StackPanel Orientation="Horizontal">
......@@ -555,18 +555,23 @@
Width="100"
Height="40"
Margin="5"
Command="{Binding Path=HoldonCommand}"
Content="Holdon"
Style="{StaticResource ButtonStyle}" />
<Button
Width="100"
Height="40"
Margin="15,5,0,5"
Command="{Binding Path=GoOnCommand}"
Content="GoOn"
Style="{StaticResource ButtonStyle}" />
<Button
Width="100"
Height="40"
Margin="15,5,0,5"
Command="{Binding Path=HoldonCommand}"
Content="Holdon"
Margin="20,5,0,5"
Command="{Binding Path=ResetCommand}"
Content="Reset"
Style="{StaticResource ButtonStyle}" />
</StackPanel>
</GroupBox>
......@@ -610,7 +615,7 @@
<GroupBox
Grid.Row="2"
Grid.Column="2"
Grid.Column="3"
Grid.ColumnSpan="4"
Foreground="White"
Header="二次确认">
......
......@@ -106,6 +106,8 @@ namespace VIZ.FGOUT.Module
this.GoOnCommand = new VCommand(this.GoOn);
//算法Holdon
this.HoldonCommand = new VCommand(this.Holdon);
//算法Reset
this.ResetCommand = new VCommand(this.Reset);
//算法开始抠图
this.MattStartCommand = new VCommand(this.MattStart);
//算法结束抠图
......@@ -657,6 +659,18 @@ namespace VIZ.FGOUT.Module
manager.SendJson(new AlgorithmPackage_Figout_model() { signal = AlgorithmPackageSignal.HOLD_ON });
}
public VCommand ResetCommand { get; set; }
private void Reset()
{
var manager = ConnectionManager.UdpConnection.GetEndpointManager(NDIViewKeys.CAM_1);
if (manager == null) return;
manager.SendJson(new AlgorithmPackage_Figout_model() { signal = AlgorithmPackageSignal.Reset });
}
/// <summary>
/// 开始抠图
/// </summary>
public VCommand MattStartCommand { get; set; }
private void MattStart()
......@@ -668,6 +682,10 @@ namespace VIZ.FGOUT.Module
mode = AlgorithmPackageSignal.manual_mode;
manager.SendJson(new AlgorithmPackage_Figout_model() { signal = AlgorithmPackageSignal.matt_start, mode = mode });
}
/// <summary>
/// 结束抠图
/// </summary>
public VCommand MattEndCommand { get; set; }
private void MattEnd()
......@@ -1345,7 +1363,8 @@ namespace VIZ.FGOUT.Module
this.RaisePropertyChanged(nameof(SliderStartValue));
if (!_isReplayChecked)
{
var replayModel = new ReplayModel() { IsReplay = true, IsStartValue = true, SliderValue = value};
ApplicationDomain.MessageManager.Send(replayModel);
}
}
}
......@@ -1360,7 +1379,8 @@ namespace VIZ.FGOUT.Module
this.RaisePropertyChanged(nameof(SliderEndValue));
if (!_isReplayChecked)
{
var replayModel = new ReplayModel() { IsReplay = true, IsEndValue = true, SliderValue = value };
ApplicationDomain.MessageManager.Send(replayModel);
}
}
}
......
......@@ -144,6 +144,7 @@ namespace VIZ.FGOUT.Module
return clonedStream;
}
int index = 0;
/// <summary>
/// 处理NDI流帧
/// </summary>
......@@ -159,83 +160,116 @@ namespace VIZ.FGOUT.Module
//}
//滑块开始、结束热键
//滑块开始热键
if (view.vm.IsSliderStartClicked)
{
SliderStartTimeStamp = e.Frame.TimeStamp;
//SliderStartTimeStamp = e.Frame.TimeStamp;
StartTime = e.Frame.TimeStamp;
view.vm.IsSliderStartClicked = false;
}
//滑块结束热键
else if (view.vm.IsSliderEndClicked)
{
SliderEndTimeStamp = e.Frame.TimeStamp;
//SliderEndTimeStamp = e.Frame.TimeStamp;
EndTime = e.Frame.TimeStamp;
view.vm.IsSliderEndClicked = false;
}
//Replay
//Replay状态下
if (view.vm.IsReplay)
{
Queue<MatExtend> buffer = _frameBuffer.GetFrames();
//只生效一次
if (view.vm.IsReplayStarted)
{
view.vm.IsReplayStarted = false;
//if (view.vm.IsSliderValueChanged)
//{
Queue<MatExtend> buffer = _frameBuffer.GetFrames();
if (buffer.Count > 0)
{
var index = 0;
foreach (var matExtend in buffer)
{
if (matExtend.TimeStamp == SliderStartTimeStamp)
//遍历队列集合,先遍历到入点帧
//if (matExtend.TimeStamp == SliderStartTimeStamp)
// SliderStartValue = index;
//else if(matExtend.TimeStamp == SliderEndTimeStamp)
// break;
if (matExtend.TimeStamp == StartTime)
SliderStartValue = index;
else if(matExtend.TimeStamp == SliderEndTimeStamp)
else if (matExtend.TimeStamp == EndTime)
break;
index++;
}
//view.vm.SliderStartValue = index;
//view.vm.SliderEndValue = index;
SliderEndValue = index;
}
//}
}
else if(view.vm.IsStartValue)
{
//view.vm.IsStartValue =false;
index = SliderValue;
}
else if (view.vm.IsEndValue)
{
//view.vm.IsEndValue = false;
index = SliderValue;
}
//var index = view.vm.SliderValue;
if (index >= 500) index = 499;
if ((buffer.Count - 1) >= index)
#region 公共代码
//var index = view.vm.SliderValue;
if (index >= 500) index = 499;
if ((buffer.Count - 1) >= index)
{
var dse = buffer.ElementAt(index);
var lowResolutionData = new byte[dse.Mat.Width * dse.Mat.Height * 4];
var newLength = lowResolutionData.Length;
Marshal.Copy(dse.Mat.Data, lowResolutionData, 0, newLength);
var dsExtend = new DataStreamExtend()
{
DataStream = new DataStream((int)newLength, true, true),
Width = dse.Mat.Width,
Height = dse.Mat.Height,
Length = newLength,
TimeStamp = NDIViewModel.ReplayTimeStamp = dse.TimeStamp
};
dsExtend.DataStream.Write(lowResolutionData, 0, newLength);
dsExtend.DataStream.Position = 0;
if (view.vm.IsStartValue)
StartTime = dse.TimeStamp;
else if (view.vm.IsEndValue)
EndTime = dse.TimeStamp;
// Replay更新画面
WPFHelper.Invoke(() =>
{
try
{
var dse = buffer.ElementAt(index);
var lowResolutionData = new byte[dse.Mat.Width * dse.Mat.Height * 4];
var newLength = lowResolutionData.Length;
Marshal.Copy(dse.Mat.Data, lowResolutionData, 0, newLength);
var dsExtend = new DataStreamExtend()
{
DataStream = new DataStream((int)newLength, true, true),
Width = dse.Mat.Width,
Height = dse.Mat.Height,
Length = newLength,
TimeStamp = NDIViewModel.ReplayTimeStamp = dse.TimeStamp
};
dsExtend.DataStream.Write(lowResolutionData, 0, newLength);
dsExtend.DataStream.Position = 0;
// Replay更新画面
WPFHelper.Invoke(() =>
{
try
{
var view3 = this.FindChild<NDIView>(Application.Current.MainWindow, "cam3");
view3.video.UpdateVideoFrame(dsExtend, true);
}
catch (Exception ex)
{
log.Error(ex);
}
});
//view.video.UpdateVideoFrame(dse, true);
var view3 = this.FindChild<NDIView>(Application.Current.MainWindow, "cam3");
view3.video.UpdateVideoFrame(dsExtend, true);
}
}
//}
catch (Exception ex)
{
log.Error(ex);
}
});
//view.video.UpdateVideoFrame(dse, true);
}
view.vm.IsStartValue = false;
view.vm.IsEndValue = false;
#endregion
}
else
{
index = 0;
#region 注释的代码
//缓存策略1
......
......@@ -215,10 +215,6 @@ namespace VIZ.FGOUT.Module
StartTime = ReplayTimeStamp;
}
public long StartTime { get; set; }
public long EndTime { get; set; }
private void ReplayStart(ReplayStartModel replayStartModel)
{
if (this.ViewKey != NDIViewKeys.CAM_3)
......@@ -356,12 +352,16 @@ namespace VIZ.FGOUT.Module
public bool IsSliderValueChanged;
public bool IsReplay;
public bool IsReplayStarted;
public bool IsStartValue;
public bool IsEndValue;
public bool IsSliderStartClicked;
public bool IsSliderEndClicked;
public long SliderStartTimeStamp;
public long SliderEndTimeStamp;
//public long SliderStartTimeStamp;
//public long SliderEndTimeStamp;
public static int SliderStartValue;
public static int SliderEndValue;
public static long StartTime { get; set; }
public static long EndTime { get; set; }
/// <summary>
/// Replay选中和SliderValueChanged传值共用这一个方法
......@@ -371,6 +371,8 @@ namespace VIZ.FGOUT.Module
if (this.ViewKey == NDIViewKeys.CAM_2)
return;
IsReplayStarted = replayModel.IsReplayStarted;
IsStartValue = replayModel.IsStartValue;
IsEndValue = replayModel.IsEndValue;
IsReplay = replayModel.IsReplay;
if (IsReplay)
_autoSend_Timer.Stop();//自动发送计时器取消
......
......@@ -13,7 +13,7 @@ namespace VIZ.FGOUT.Module
private static int _width = 150; // 拖动条初始宽度
private static int _height = 30; // 高度
private static int _min = 0; // 最小值
private static int _max = 100; // 最大值
private static int _max = 500; // 最大值
private static int _freq = 1; // 出现刻度的间距
#endregion
......
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "BA45359DEBE104D5559D3FAE8AF08CE958BED95BFD327E141845FDF99A44BCEC"
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "00FCD7D89DA29839EA9C560AE3F87499AA11AE2896966BABE4001E595BE3F24C"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
......@@ -74,7 +74,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 1024 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 1029 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam1;
......@@ -82,7 +82,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 1073 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 1078 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam2;
......@@ -90,7 +90,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 1088 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 1093 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam3;
......
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "BA45359DEBE104D5559D3FAE8AF08CE958BED95BFD327E141845FDF99A44BCEC"
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "00FCD7D89DA29839EA9C560AE3F87499AA11AE2896966BABE4001E595BE3F24C"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
......@@ -74,7 +74,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 1024 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 1029 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam1;
......@@ -82,7 +82,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 1073 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 1078 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam2;
......@@ -90,7 +90,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 1088 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 1093 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam3;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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