Commit 58136158 by 鲁志-悦动

只在调整入点的时候显示入点跟踪框 And 入点和入点跟踪框不一致加提示 And 有入点跟踪框的时候点选的入点框数据清空 And 修复双人项目有入点跟踪框的情况下只发送一人数据的缺陷

parent 1b842e9b
......@@ -10,11 +10,11 @@ none
false
DEBUG;TRACE
22-1578589972
1-1441241311
11-1602666439
23-2035776870
221979955803
1470602451
11-350624472
24-1321085892
Resources\StringResource.zh-CN.xaml;Resources\StringResource.en.xaml;Style\Button\Button_NdiView.xaml;Style\Button\Button_Setting.xaml;Style\Button\Button_WindowTop.xaml;Style\CheckBox\CheckBox_NdiView.xaml;Style\CheckBox\CheckBox_RaidoButtonStyle.xaml;Style\CheckBox\CheckBox_Setting.xaml;Style\CheckBox\CheckBox_WindowTop.xaml;Style\ComboBox\ComboBox_Setting.xaml;Style\HotkeyBox\HotkeyBox_Setting.xaml;Style\MessageBox\MessageBoxEx.xaml;Style\RadioButton\RadioButton_FootballSide.xaml;Style\RadioButton\RadioButton_NdiMainViewBlue.xaml;Style\RadioButton\RadioButton_NdiView.xaml;Style\RadioButton\RadioButton_Setting.xaml;Style\Slider\Slider_Setting.xaml;Style\TextBlock\TextBlock_Setting.xaml;Style\TextBox\TextBox_Setting.xaml;Style\ToogleButton\ToogleButton_Setting.xaml;Themes\Generic.xaml;Toolkit\NumericUpDown\NumericUpDown.xaml;
True
False
......@@ -46,9 +46,9 @@ namespace VIZ.FGOUT.Module
public Rect rectReplay;
// public Rectangle rectInvalid;
public List<Rect> rectsReplay = new List<Rect>();
public TrackingBoxInfo saveInfo = new TrackingBoxInfo();
public List<TrackingBoxInfo> saveInfos = new List<TrackingBoxInfo>();
public static List<Rect> rectsReplay = new List<Rect>();
public static TrackingBoxInfo saveInfo = new TrackingBoxInfo();
public static List<TrackingBoxInfo> saveInfos = new List<TrackingBoxInfo>();
// public Path myPath = new Path();
// public Path myPath1 = new Path();
......
......@@ -164,399 +164,435 @@ namespace VIZ.FGOUT.Module
/// </summary>
private void NDIStream_ExecuteVideoFrame(object sender, VideoFrameEventArgs e)
{
var view = this.GetView<NDIView>();
if (view == null)
return;
try
{
var view = this.GetView<NDIView>();
if (view == null)
return;
//不能这么判断,会崩,要用WPFHelper.Invoke这个
//if (view.NDIKey == NDIViewKeys.CAM_3)
//{
//不能这么判断,会崩,要用WPFHelper.Invoke这个
//if (view.NDIKey == NDIViewKeys.CAM_3)
//{
//}
//}
//入点热键
if (view.vm.IsSliderStartClicked)
{
//SliderStartTimeStamp = e.Frame.TimeStamp;
StartTime = e.Frame.TimeStamp;
view.vm.IsSliderStartClicked = false;
}
//出点热键
else if (view.vm.IsSliderEndClicked)
{
//SliderEndTimeStamp = e.Frame.TimeStamp;
EndTime = e.Frame.TimeStamp;
view.vm.IsSliderEndClicked = false;
}
//入点热键
if (view.vm.IsSliderStartClicked)
{
//SliderStartTimeStamp = e.Frame.TimeStamp;
StartTime = e.Frame.TimeStamp;
view.vm.IsSliderStartClicked = false;
}
//出点热键
else if (view.vm.IsSliderEndClicked)
{
//SliderEndTimeStamp = e.Frame.TimeStamp;
EndTime = e.Frame.TimeStamp;
view.vm.IsSliderEndClicked = false;
}
//在Replay状态下
if (view.vm.IsReplay)
{
Queue<MatExtend> buffer = _frameBuffer.GetFrames();
//只生效一次
if (view.vm.IsReplayStarted)
//在Replay状态下
if (view.vm.IsReplay)
{
view.vm.IsReplayStarted = false;
Queue<MatExtend> buffer = _frameBuffer.GetFrames();
//只生效一次
if (view.vm.IsReplayStarted)
{
view.vm.IsReplayStarted = false;
//if(view.vm.ReplayInPointStartTime > 0)
// StartTime = view.vm.ReplayInPointStartTime;
//if(view.vm.ReplayOutPointEndTime > 0)
// EndTime = view.vm.ReplayOutPointEndTime;
//if(view.vm.ReplayInPointStartTime > 0)
// StartTime = view.vm.ReplayInPointStartTime;
//if(view.vm.ReplayOutPointEndTime > 0)
// EndTime = view.vm.ReplayOutPointEndTime;
//if (view.vm.IsSliderValueChanged)
//{
if (buffer.Count > 0)
{
foreach (var matExtend in buffer)
//if (view.vm.IsSliderValueChanged)
//{
if (buffer.Count > 0)
{
//遍历队列集合,先遍历到入点帧
//if (matExtend.TimeStamp == SliderStartTimeStamp)
// SliderStartValue = index;
//else if(matExtend.TimeStamp == SliderEndTimeStamp)
// break;
if (matExtend.TimeStamp == StartTime)
foreach (var matExtend in buffer)
{
SliderStartValue = index;
//var replayStartValueModel = new ReplayStartValueModel() { ReplayStartValue = index};
//ApplicationDomain.MessageManager.Send(replayStartValueModel);
//遍历队列集合,先遍历到入点帧
//if (matExtend.TimeStamp == SliderStartTimeStamp)
// SliderStartValue = index;
//else if(matExtend.TimeStamp == SliderEndTimeStamp)
// break;
if (matExtend.TimeStamp == StartTime)
{
SliderStartValue = index;
//var replayStartValueModel = new ReplayStartValueModel() { ReplayStartValue = index};
//ApplicationDomain.MessageManager.Send(replayStartValueModel);
}
else if (matExtend.TimeStamp == EndTime)
break;
index++;
}
else if (matExtend.TimeStamp == EndTime)
break;
index++;
}
//view.vm.SliderStartValue = index;
//view.vm.SliderEndValue = index;
//view.vm.SliderStartValue = index;
//view.vm.SliderEndValue = index;
SliderEndValue = index;
//var replayEndValueModel = new ReplayEndValueModel() { ReplayEndValue = index };
//ApplicationDomain.MessageManager.Send(replayEndValueModel);
SliderEndValue = index;
//var replayEndValueModel = new ReplayEndValueModel() { ReplayEndValue = index };
//ApplicationDomain.MessageManager.Send(replayEndValueModel);
}
//}
}
//}
}
//如果是Start滑块在动
else if (view.vm.IsStartValue)
{
//view.vm.IsStartValue =false;
SliderStartValue = index = SliderValue;
}
//如果是End滑块在动
else if (view.vm.IsEndValue)
{
//view.vm.IsEndValue = false;
SliderEndValue = index = SliderValue;
}
#region 公共代码
//var index = view.vm.SliderValue;
if (index >= (50* STREAM_CACHEED_TIME)) index = (50 * STREAM_CACHEED_TIME - 1);
if ((buffer.Count - 1) >= index && index >= 0)
{
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()
//如果是Start滑块在动
else if (view.vm.IsStartValue)
{
DataStream = new DataStream((int)newLength, true, true),
Width = dse.Mat.Width,
Height = dse.Mat.Height,
Length = newLength,
TimeStamp = ReplayTimeStamp = dse.TimeStamp
};
dsExtend.DataStream.Write(lowResolutionData, 0, newLength);
dsExtend.DataStream.Position = 0;
//遍历跟踪框队列
Queue<TrackingBoxInfo> infoBuffers = _trackingBoxInfoBuffer.GetInfos();
Queue<TrackingBoxInfo> infoBBuffers = _trackingBBoxInfoBuffer.GetInfos();
_cam3Infos = new List<TrackingBoxInfo>();
_cam3BInfos = new List<TrackingBoxInfo>();
//_cam3UpdateInfos = new List<TrackingBoxInfo>();
//跟踪框全显示
if (infoBuffers.Count > 0)
//view.vm.IsStartValue =false;
SliderStartValue = index = SliderValue;
}
//如果是End滑块在动
else if (view.vm.IsEndValue)
{
foreach (var info in infoBuffers)
{
if (info == null) continue;
if (info.TimeCode == dse.TimeStamp)
_cam3Infos.Add(info);
}
//view.vm.IsEndValue = false;
SliderEndValue = index = SliderValue;
}
//匹配的时候只匹配BBox下的
if (infoBBuffers.Count > 0)
#region 公共代码
//var index = view.vm.SliderValue;
if (index >= (50 * STREAM_CACHEED_TIME)) index = (50 * STREAM_CACHEED_TIME - 1);
if ((buffer.Count - 1) >= index && index >= 0)
{
foreach (var info in infoBBuffers)
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 = ReplayTimeStamp = dse.TimeStamp
};
dsExtend.DataStream.Write(lowResolutionData, 0, newLength);
dsExtend.DataStream.Position = 0;
//遍历跟踪框队列
Queue<TrackingBoxInfo> infoBuffers = _trackingBoxInfoBuffer.GetInfos();
Queue<TrackingBoxInfo> infoBBuffers = _trackingBBoxInfoBuffer.GetInfos();
_cam3Infos = new List<TrackingBoxInfo>();
_cam3BInfos = new List<TrackingBoxInfo>();
//_cam3UpdateInfos = new List<TrackingBoxInfo>();
//跟踪框全显示
if (infoBuffers.Count > 0)
{
if (info == null) continue;
if (info.TimeCode == dse.TimeStamp)
_cam3BInfos.Add(info);
foreach (var info in infoBuffers)
{
if (info == null) continue;
if (info.TimeCode == dse.TimeStamp)
_cam3Infos.Add(info);
}
}
#region 算法track到人的情况下跟踪框标红
if (_cam3BInfos.Count > 0)
//匹配的时候只匹配BBox下的
if (infoBBuffers.Count > 0)
{
var info2 = _cam3BInfos[0];
if (info2.BboxType != null && info2.BboxType.Equals(AlgorithmPackageSignal.track))
foreach (var info in infoBBuffers)
{
var gameName = ApplicationDomainEx.LiteDbContext.ViewConfig
.FindOne(p => p.ViewKey == NDIViewKeys.CAM_1).GameName;
//当双人3m跳水,双人10m跳水,双人速度攀岩时,保存2个入点框
if (gameName.Equals(SportsProjectCodes.SS) || gameName.Equals(SportsProjectCodes.ST) ||
gameName.Equals(SportsProjectCodes.SP))
if (info == null) continue;
if (info.TimeCode == dse.TimeStamp)
_cam3BInfos.Add(info);
}
#region 算法track到人的情况下跟踪框标红
if (_cam3BInfos.Count > 0 && view.vm.IsStartValue)
{
var info2 = _cam3BInfos[0];
if (info2.BboxType != null && info2.BboxType.Equals(AlgorithmPackageSignal.track))
{
_twoInfos = new List<TrackingBoxInfo>();
foreach (var saveInfo in _cam3BInfos)
var gameName = ApplicationDomainEx.LiteDbContext.ViewConfig
.FindOne(p => p.ViewKey == NDIViewKeys.CAM_1).GameName;
//当双人3m跳水,双人10m跳水,双人速度攀岩时,保存2个入点框
if (gameName.Equals(SportsProjectCodes.SS) ||
gameName.Equals(SportsProjectCodes.ST) ||
gameName.Equals(SportsProjectCodes.SP))
{
_twoInfos = new List<TrackingBoxInfo>();
foreach (var saveInfo in _cam3BInfos)
{
//更新红色点中框
saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(saveInfo);
//记录标红框时入点时间戳
_RecordStartTime = saveInfo.TimeCode;
//赋值
_twoInfos.Add(saveInfo);
//清除点选跟踪框的数据
//view.saveInfos = new List<TrackingBoxInfo>();
NDIView.saveInfos = new List<TrackingBoxInfo>();
}
}
else
{
//更新红色点中框
saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//单人更新红色点中框
info2.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(saveInfo);
_cam3Infos.Add(info2);
//记录标红框时入点时间戳
_RecordStartTime = saveInfo.TimeCode;
_RecordStartTime = info2.TimeCode;
_twoInfos.Add(saveInfo);
//赋值
_singleInfo = info2;
}
}
else
{
//单人更新红色点中框
info2.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(info2);
//记录标红框时入点时间戳
_RecordStartTime = info2.TimeCode;
_singleInfo = info2;
//清除点选跟踪框的数据
//view.saveInfo = new TrackingBoxInfo();
NDIView.saveInfo = new TrackingBoxInfo();
//清除拖框的数据
//view.rectsReplay.Clear();
NDIView.rectsReplay.Clear();
}
}
#endregion
}
#endregion
}
//如果是Start滑块在动
if (view.vm.IsStartValue)
StartTime = dse.TimeStamp;
else if (view.vm.IsEndValue)
EndTime = dse.TimeStamp;
//如果是Start滑块在动
if (view.vm.IsStartValue)
StartTime = dse.TimeStamp;
else if (view.vm.IsEndValue)
EndTime = dse.TimeStamp;
// Replay更新画面
WPFHelper.BeginInvoke(() =>
{
try
// Replay更新画面
WPFHelper.BeginInvoke(() =>
{
var view3 = this.FindChild<NDIView>(Application.Current.MainWindow, NDIViewKeys.cam3);
if (view3 != null)
try
{
// 更新视频流
view3.video.UpdateVideoFrame(dsExtend, true);
#region 注释的代码
//// 更新视频控件跟踪框信息,现在_cam3Infos里是缓存的跟踪框信息
//if (_cam3Infos.Count > 0)
//{
// _cam3StaticInfos = _cam3Infos;
// var gameName = ApplicationDomainEx.LiteDbContext.ViewConfig.FindOne(p => p.ViewKey == NDIViewKeys.CAM_1).GameName;
// //当双人3m跳水,双人10m跳水,双人速度攀岩时,保存2个入点框
// if (gameName.Equals("SS") || gameName.Equals("ST") || gameName.Equals("SP"))
// {
// foreach (var saveInfo in view3.saveInfos)
// {
// //更新红色点中框
// if (saveInfo.SrcRect.Left > 0)
// {
// saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
// _cam3Infos.Add(saveInfo);//把选中框的信息也加到这个集合里
// }
// }
// }
// else
// {
// //更新红色点中框
// if (view3.saveInfo.SrcRect.Left > 0)
// {
// view3.saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
// _cam3Infos.Add(view3.saveInfo);//把选中框的信息也加到这个集合里
// }
// }
// //先清除跟踪框
// //view3.video.ClearTrackingBox();
// //再更新跟踪框信息
// view3.video.UpdateTrackingBox(_cam3Infos);
//}
#endregion
// 更新视频控件跟踪框信息,现在_cam3BInfos里是缓存的跟踪框信息
if (_cam3BInfos.Count > 0)
var view3 = this.FindChild<NDIView>(Application.Current.MainWindow, NDIViewKeys.cam3);
if (view3 != null)
{
_cam3StaticInfos = _cam3BInfos;
var gameName = ApplicationDomainEx.LiteDbContext.ViewConfig.FindOne(p => p.ViewKey == NDIViewKeys.CAM_1).GameName;
//当双人3m跳水,双人10m跳水,双人速度攀岩时,保存2个入点框
//if (gameName.Equals("SS") || gameName.Equals("ST") || gameName.Equals("SP"))
if (gameName.Equals(SportsProjectCodes.SS) || gameName.Equals(SportsProjectCodes.ST) || gameName.Equals(SportsProjectCodes.SP))
// 更新视频流
view3.video.UpdateVideoFrame(dsExtend, true);
#region 注释的代码
//// 更新视频控件跟踪框信息,现在_cam3Infos里是缓存的跟踪框信息
//if (_cam3Infos.Count > 0)
//{
// _cam3StaticInfos = _cam3Infos;
// var gameName = ApplicationDomainEx.LiteDbContext.ViewConfig.FindOne(p => p.ViewKey == NDIViewKeys.CAM_1).GameName;
// //当双人3m跳水,双人10m跳水,双人速度攀岩时,保存2个入点框
// if (gameName.Equals("SS") || gameName.Equals("ST") || gameName.Equals("SP"))
// {
// foreach (var saveInfo in view3.saveInfos)
// {
// //更新红色点中框
// if (saveInfo.SrcRect.Left > 0)
// {
// saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
// _cam3Infos.Add(saveInfo);//把选中框的信息也加到这个集合里
// }
// }
// }
// else
// {
// //更新红色点中框
// if (view3.saveInfo.SrcRect.Left > 0)
// {
// view3.saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
// _cam3Infos.Add(view3.saveInfo);//把选中框的信息也加到这个集合里
// }
// }
// //先清除跟踪框
// //view3.video.ClearTrackingBox();
// //再更新跟踪框信息
// view3.video.UpdateTrackingBox(_cam3Infos);
//}
#endregion
// 更新视频控件跟踪框信息,现在_cam3BInfos里是缓存的跟踪框信息
if (_cam3BInfos.Count > 0)
{
foreach (var saveInfo in view3.saveInfos)
_cam3StaticInfos = _cam3BInfos;
var gameName = ApplicationDomainEx.LiteDbContext.ViewConfig
.FindOne(p => p.ViewKey == NDIViewKeys.CAM_1).GameName;
//当双人3m跳水,双人10m跳水,双人速度攀岩时,保存2个入点框
//if (gameName.Equals("SS") || gameName.Equals("ST") || gameName.Equals("SP"))
if (gameName.Equals(SportsProjectCodes.SS) ||
gameName.Equals(SportsProjectCodes.ST) ||
gameName.Equals(SportsProjectCodes.SP))
{
foreach (var saveInfo in NDIView.saveInfos)
//foreach (var saveInfo in view3.saveInfos)
{
//更新红色点中框
if (saveInfo.SrcRect.Left > 0)
{
saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(saveInfo);
//_cam3UpdateInfos.Add(saveInfo);
//记录标红框时入点时间戳
_RecordStartTime = saveInfo.TimeCode;
}
}
//view3.video.UpdateTrackingBox(_cam3UpdateInfos);
//记录标红框时入点时间戳
//_RecordStartTime = StartTime;
}
else
{
//单人
//var info = view3.saveInfo;
var info = NDIView.saveInfo;
//更新红色点中框
if (saveInfo.SrcRect.Left > 0)
if (info.SrcRect.Left > 0)
{
saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
info.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(saveInfo);
//_cam3UpdateInfos.Add(saveInfo);
_cam3Infos.Add(info);
//view3.video.UpdateTrackingBox(new List<TrackingBoxInfo>(){ info });
//记录标红框时入点时间戳
_RecordStartTime = saveInfo.TimeCode;
//_RecordStartTime = StartTime;
_RecordStartTime = info.TimeCode;
}
}
//view3.video.UpdateTrackingBox(_cam3UpdateInfos);
//记录标红框时入点时间戳
//_RecordStartTime = StartTime;
}
else
{
//单人
var info = view3.saveInfo;
//更新红色点中框
if (info.SrcRect.Left > 0)
{
info.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(info);
//view3.video.UpdateTrackingBox(new List<TrackingBoxInfo>(){ info });
//记录标红框时入点时间戳
//_RecordStartTime = StartTime;
_RecordStartTime = info.TimeCode;
}
//先清除跟踪框
//view3.video.ClearTrackingBox();
//再更新跟踪框信息
view3.video.UpdateTrackingBox(_cam3Infos);
}
//先清除跟踪框
//view3.video.ClearTrackingBox();
//再更新跟踪框信息
view3.video.UpdateTrackingBox(_cam3Infos);
}
}
}
catch (Exception ex)
{
log.Error(ex);
}
});
}
view.vm.IsStartValue = false;
view.vm.IsEndValue = false;
catch (Exception ex)
{
log.Error(ex);
}
});
}
#endregion
}
else
{
index = 0;
#region 注释的代码
//缓存策略1
//dsExtend.DataStream = DeepCloneDataStream(e.Frame.DataStream);
//dsExtend.Width = e.Frame.Width;
//dsExtend.Height = e.Frame.Height;
//dsExtend.TimeStamp = e.Frame.TimeStamp;
//_frameBuffer.AddFrame(dsExtend);
#endregion
//缓存策略2
// 将视频帧转换为Mat对象
//var t1 = DateTime.Now;
var mat = new Mat(e.Frame.Height, e.Frame.Width, MatType.CV_8UC4, e.Frame.DataStream.DataPointer);
// 将帧缩放到低分辨率
var resizedFrame = new Mat();
//Cv2.Resize(mat, resizedFrame, new Size(mat.Width / 4 , mat.Height / 4));
Cv2.Resize(mat, resizedFrame, new OpenCvSharp.Size(mat.Width, mat.Height));
//时间戳获取
timecode = e.Frame.TimeStamp;
//_frameBuffer.AddFrame(resizedFrame);
_frameBuffer.AddFrame(new MatExtend(){ Mat = resizedFrame, TimeStamp = timecode });
// 释放视频帧资源
mat.Dispose();
#region 注释的代码
//原始帧直接放到队列
//var mat = new Mat(e.Frame.Height, e.Frame.Width, MatType.CV_8UC4, e.Frame.DataStream.DataPointer);
//_frameBuffer.AddFrame(mat);
//var t2 = DateTime.Now;
//var minus = (t2 - t1).TotalMilliseconds;
////时间戳获取
//timecode = e.Frame.TimeStamp;
// 更新画面 4K流优化
//var mat2 = new Mat(e.Frame.Height, e.Frame.Width, MatType.CV_8UC4, e.Frame.DataStream.DataPointer);
//var resizedFrame2 = new Mat();
//Cv2.Resize(mat2, resizedFrame2, new Size(mat2.Width / 4, mat2.Height / 4));
//byte[] lowResolutionData = new byte[resizedFrame2.Width * resizedFrame2.Height * 4];
//var newLength = lowResolutionData.Length;
//Marshal.Copy(resizedFrame2.Data, lowResolutionData, 0, newLength);
//DataStreamExtend dsExtend = new DataStreamExtend();
//dsExtend.DataStream = new DataStream((int)newLength, true, true);
//dsExtend.DataStream.Write(lowResolutionData, 0, newLength);
//dsExtend.DataStream.Position = 0;
//dsExtend.Width = resizedFrame2.Width;
//dsExtend.Height = resizedFrame2.Height;
//dsExtend.Length = newLength;
//dsExtend.TimeStamp = NDIViewModel.ReplayTimeStamp = e.Frame.TimeStamp;
//view.video.UpdateVideoFrame(dsExtend);
#endregion
view.vm.IsStartValue = false;
view.vm.IsEndValue = false;
}
// 更新画面
view.video.UpdateVideoFrame(e.Frame);
#endregion
}
else
{
index = 0;
#region 注释的代码
//缓存策略1
//dsExtend.DataStream = DeepCloneDataStream(e.Frame.DataStream);
//dsExtend.Width = e.Frame.Width;
//dsExtend.Height = e.Frame.Height;
//dsExtend.TimeStamp = e.Frame.TimeStamp;
//_frameBuffer.AddFrame(dsExtend);
#endregion
//缓存策略2
// 将视频帧转换为Mat对象
//var t1 = DateTime.Now;
var mat = new Mat(e.Frame.Height, e.Frame.Width, MatType.CV_8UC4, e.Frame.DataStream.DataPointer);
// 将帧缩放到低分辨率
var resizedFrame = new Mat();
//Cv2.Resize(mat, resizedFrame, new Size(mat.Width / 4 , mat.Height / 4));
Cv2.Resize(mat, resizedFrame, new OpenCvSharp.Size(mat.Width, mat.Height));
//时间戳获取
timecode = e.Frame.TimeStamp;
//_frameBuffer.AddFrame(resizedFrame);
_frameBuffer.AddFrame(new MatExtend() { Mat = resizedFrame, TimeStamp = timecode });
// 释放视频帧资源
mat.Dispose();
#region 注释的代码
//原始帧直接放到队列
//var mat = new Mat(e.Frame.Height, e.Frame.Width, MatType.CV_8UC4, e.Frame.DataStream.DataPointer);
//_frameBuffer.AddFrame(mat);
//var t2 = DateTime.Now;
//var minus = (t2 - t1).TotalMilliseconds;
////时间戳获取
//timecode = e.Frame.TimeStamp;
// 更新画面 4K流优化
//var mat2 = new Mat(e.Frame.Height, e.Frame.Width, MatType.CV_8UC4, e.Frame.DataStream.DataPointer);
//var resizedFrame2 = new Mat();
//Cv2.Resize(mat2, resizedFrame2, new Size(mat2.Width / 4, mat2.Height / 4));
//byte[] lowResolutionData = new byte[resizedFrame2.Width * resizedFrame2.Height * 4];
//var newLength = lowResolutionData.Length;
//Marshal.Copy(resizedFrame2.Data, lowResolutionData, 0, newLength);
//DataStreamExtend dsExtend = new DataStreamExtend();
//dsExtend.DataStream = new DataStream((int)newLength, true, true);
//dsExtend.DataStream.Write(lowResolutionData, 0, newLength);
//dsExtend.DataStream.Position = 0;
//dsExtend.Width = resizedFrame2.Width;
//dsExtend.Height = resizedFrame2.Height;
//dsExtend.Length = newLength;
//dsExtend.TimeStamp = NDIViewModel.ReplayTimeStamp = e.Frame.TimeStamp;
//view.video.UpdateVideoFrame(dsExtend);
#endregion
// 更新手动裁切框
// 仅手动模式下处理 & 居中模式下处理 & 需要进行裁切时才处理
if ((this.StrategyMode == AlgorithmStrategyMode.center_mode || this.StrategyMode == AlgorithmStrategyMode.manual_mode) && this.IsUseClip)
this.UpdateClipBoxWithManualAndCenter();
}
// 获取将要发送的裁切数据, 无论什么模式均要发送
Navigation3DSmoothWithSavitzkyGolayResult sendValue = this.ManualController.GetSavitzkyGolayValue(e.Frame.TimeStamp, this.ClipBoxX + ApplicationDomainEx.VIDEO_CLIP_BOX_WIDTH / 2);
// 更新画面
view.video.UpdateVideoFrame(e.Frame);
// 如果当前模式为手动模式或居中模式且处于接收裁切信号状态,并且需要进行裁切,那么发送手动裁切信号 && this.ViewStatus == NDIViewStatus.CropRoi
if (e.Frame != null && this.IsUseClip
&& (this.StrategyMode == AlgorithmStrategyMode.center_mode || this.StrategyMode == AlgorithmStrategyMode.manual_mode))
{
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(this.ViewKey);
if (manager == null)
return;
// 更新手动裁切框
// 仅手动模式下处理 & 居中模式下处理 & 需要进行裁切时才处理
if ((this.StrategyMode == AlgorithmStrategyMode.center_mode ||
this.StrategyMode == AlgorithmStrategyMode.manual_mode) && this.IsUseClip)
this.UpdateClipBoxWithManualAndCenter();
List<int> roi = this.GetManulRoi();
// 向算法发送裁切框
if (this.StrategyMode == AlgorithmStrategyMode.center_mode)
AlgorithmSender.CenterMode(manager, this.ID, this.ViewConfig.IsSendToCrop, roi, this.AlgorithmConfig.SmoothCoeff);
else if (this.StrategyMode == AlgorithmStrategyMode.manual_mode)
AlgorithmSender.ManualMode(manager, this.ID, this.ViewConfig.IsSendToCrop, roi, this.AlgorithmConfig.SmoothCoeff);
// 获取将要发送的裁切数据, 无论什么模式均要发送
Navigation3DSmoothWithSavitzkyGolayResult sendValue =
this.ManualController.GetSavitzkyGolayValue(e.Frame.TimeStamp,
this.ClipBoxX + ApplicationDomainEx.VIDEO_CLIP_BOX_WIDTH / 2);
// 在需要发送裁切框时
//if (this.viewConfig.IsSendToCrop)
//{
// UdpEndpointManager manager_clip = ConnectionManager.UdpConnection.GetEndpointManager($"{this.ViewKey}__CLIP");
// if (manager_clip != null)
// {
// ClipSender.CropRoi(manager_clip, 0, this.GetManulRoi((int)sendValue.Value), ApplicationDomainEx.VIDEO_CLIP_BOX_WIDTH, e.Frame.Height, sendValue.TimeCode);
// }
//}
// 如果当前模式为手动模式或居中模式且处于接收裁切信号状态,并且需要进行裁切,那么发送手动裁切信号 && this.ViewStatus == NDIViewStatus.CropRoi
if (e.Frame != null && this.IsUseClip
&& (this.StrategyMode == AlgorithmStrategyMode.center_mode ||
this.StrategyMode == AlgorithmStrategyMode.manual_mode))
{
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(this.ViewKey);
if (manager == null) return;
List<int> roi = this.GetManulRoi();
// 向算法发送裁切框
if (this.StrategyMode == AlgorithmStrategyMode.center_mode)
AlgorithmSender.CenterMode(manager, this.ID, this.ViewConfig.IsSendToCrop, roi,
this.AlgorithmConfig.SmoothCoeff);
else if (this.StrategyMode == AlgorithmStrategyMode.manual_mode)
AlgorithmSender.ManualMode(manager, this.ID, this.ViewConfig.IsSendToCrop, roi,
this.AlgorithmConfig.SmoothCoeff);
// 在需要发送裁切框时
//if (this.viewConfig.IsSendToCrop)
//{
// UdpEndpointManager manager_clip = ConnectionManager.UdpConnection.GetEndpointManager($"{this.ViewKey}__CLIP");
// if (manager_clip != null)
// {
// ClipSender.CropRoi(manager_clip, 0, this.GetManulRoi((int)sendValue.Value), ApplicationDomainEx.VIDEO_CLIP_BOX_WIDTH, e.Frame.Height, sendValue.TimeCode);
// }
//}
// 统计裁切FPS(20240305注释)
//this.ClipFPS.CalcFps();
// 统计裁切FPS(20240305注释)
//this.ClipFPS.CalcFps();
}
}
catch (Exception ex)
{
log.Error(ex);
return;
}
}
}
......
......@@ -263,18 +263,40 @@ namespace VIZ.FGOUT.Module
//前三个手拖框、双人项目、单人项目都是判断是否有值
//手拖框
if (nDIView.rectsReplay.Count > 0 && nDIView.rectsReplay[0].Width > 0 && nDIView.rectsReplay[0].Height > 0)
//if (nDIView.rectsReplay.Count > 0 && nDIView.rectsReplay[0].Width > 0 && nDIView.rectsReplay[0].Height > 0)
//{
// inPoints = Coordinate(nDIView.rectsReplay, srcWidth, srcHeight);
// isInPoint = true;
//}
if (NDIView.rectsReplay.Count > 0 && NDIView.rectsReplay[0].Width > 0 && NDIView.rectsReplay[0].Height > 0)
{
inPoints = Coordinate(nDIView.rectsReplay, srcWidth, srcHeight);
inPoints = Coordinate(NDIView.rectsReplay, srcWidth, srcHeight);
isInPoint = true;
}
//双人项目
else if(nDIView.saveInfos.Count > 0)
//else if(nDIView.saveInfos.Count > 0)
//{
// if (nDIView.saveInfos.Count == 2)
// {
// if (InPointIsMoved()) return; //入点和入点标记框位置不一致,返回
// inPoints = CoordinateTrackingBoxInfos(nDIView.saveInfos, srcWidth, srcHeight);
// isInPoint = true;
// }
// else
// {
// WPFHelper.BeginInvoke(() =>
// {
// MessageBoxEx.ShowDialog("双人比赛项目应选择两个入点.");
// });
// return;
// }
//}
else if (NDIView.saveInfos.Count > 0)
{
if (nDIView.saveInfos.Count == 2)
if (NDIView.saveInfos.Count == 2)
{
if (InPointIsMoved()) return; //入点和入点标记框位置不一致,返回
inPoints = CoordinateTrackingBoxInfos(nDIView.saveInfos, srcWidth, srcHeight);
inPoints = CoordinateTrackingBoxInfos(NDIView.saveInfos, srcWidth, srcHeight);
isInPoint = true;
}
else
......@@ -296,21 +318,29 @@ namespace VIZ.FGOUT.Module
// isInPoint = true;
// }
//}
else if (nDIView.saveInfo.SrcRect.Left > 0)
//else if (nDIView.saveInfo.SrcRect.Left > 0)
//{
// if (InPointIsMoved()) return; //入点和入点标记框位置不一致,返回
// inPoints = CoordinateTrackingBoxInfo(nDIView.saveInfo.SrcRect, srcWidth, srcHeight);
// isInPoint = true;
//}
else if (NDIView.saveInfo.SrcRect.Left > 0)
{
if (InPointIsMoved()) return; //入点和入点标记框位置不一致,返回
inPoints = CoordinateTrackingBoxInfo(nDIView.saveInfo.SrcRect, srcWidth, srcHeight);
inPoints = CoordinateTrackingBoxInfo(NDIView.saveInfo.SrcRect, srcWidth, srcHeight);
isInPoint = true;
}
#region 算法识别到人的情况下
else if (_twoInfos.Count > 0)
{
if (InPointIsMoved()) return; //入点和入点标记框位置不一致,返回
inPoints = CoordinateTrackingBoxInfos(_twoInfos, srcWidth, srcHeight);
isInPoint = true;
}
else if (_singleInfo.SrcRect.Left > 0)
{
if (InPointIsMoved()) return; //入点和入点标记框位置不一致,返回
inPoints = CoordinateTrackingBoxInfo(_singleInfo.SrcRect, srcWidth, srcHeight);
isInPoint = true;
}
......@@ -361,11 +391,14 @@ namespace VIZ.FGOUT.Module
if (this.ViewKey != NDIViewKeys.CAM_3) return;
var ndiView = this.GetView<NDIView>();
if (ndiView == null) return;
ndiView.rectsReplay.Clear();
//ndiView.rectsReplay.Clear();
NDIView.rectsReplay.Clear();
ndiView.canvas1.Children.Clear();
//清除跟踪框的数据
ndiView.saveInfo = new TrackingBoxInfo();
ndiView.saveInfos = new List<TrackingBoxInfo>();
//ndiView.saveInfo = new TrackingBoxInfo();
//ndiView.saveInfos = new List<TrackingBoxInfo>();
NDIView.saveInfo = new TrackingBoxInfo();
NDIView.saveInfos = new List<TrackingBoxInfo>();
_singleInfo = new TrackingBoxInfo();
_twoInfos = new List<TrackingBoxInfo>();
......@@ -522,16 +555,32 @@ namespace VIZ.FGOUT.Module
NDIView nDIView = this.GetView<NDIView>();
if (nDIView == null) return;
//清除拖框的数据
nDIView.rectsReplay.Clear();
//nDIView.rectsReplay.Clear();
NDIView.rectsReplay.Clear();
nDIView.canvas1.Children.Clear();
//清除跟踪框的数据
nDIView.saveInfo = new TrackingBoxInfo();
nDIView.saveInfos = new List<TrackingBoxInfo>();
//nDIView.saveInfo = new TrackingBoxInfo();
//nDIView.saveInfos = new List<TrackingBoxInfo>();
NDIView.saveInfo = new TrackingBoxInfo();
NDIView.saveInfos = new List<TrackingBoxInfo>();
_singleInfo = new TrackingBoxInfo();
_twoInfos = new List<TrackingBoxInfo>();
}
}
/// <summary>
/// 清除拖框和跟踪框的数据
/// </summary>
//private void ClearMoveAndTrackRectangleBoxData()
//{
// //清除拖框的数据
// nDIView.rectsReplay.Clear();
// nDIView.canvas1.Children.Clear();
// //清除跟踪框的数据
// nDIView.saveInfo = new TrackingBoxInfo();
// nDIView.saveInfos = new List<TrackingBoxInfo>();
//}
public bool IsMark;
/// <summary>
/// 算法标记命令
......@@ -1749,8 +1798,10 @@ namespace VIZ.FGOUT.Module
// view.rectsInvalid.RemoveAt(view.rectsInvalid.Count - 1);
else if (IsDrawInvalidPlace && view.polygonsInvalid.Count > 0)
view.polygonsInvalid.RemoveAt(view.polygonsInvalid.Count - 1);
else if (IsReplay && view.rectsReplay.Count > 0)
view.rectsReplay.RemoveAt(view.rectsReplay.Count - 1);
//else if (IsReplay && view.rectsReplay.Count > 0)
// view.rectsReplay.RemoveAt(view.rectsReplay.Count - 1);
else if (IsReplay && NDIView.rectsReplay.Count > 0)
NDIView.rectsReplay.RemoveAt(NDIView.rectsReplay.Count - 1);
//先清空
view.canvas1.Children.Clear();
......
......@@ -55,5 +55,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.8.0")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: AssemblyVersion("1.0.9.0")]
[assembly: AssemblyFileVersion("1.0.9.0")]
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