Commit 7b6c36b6 by 鲁志-悦动

优化入出点自动跟踪和手拖框混合的逻辑

parent e57a4a7c
......@@ -20,6 +20,7 @@ using VIZ.Framework.Common;
using VIZ.Framework.Connection;
using VIZ.Framework.Core;
using VIZ.Framework.Domain;
using VIZ.Framework.Storage;
using Application = System.Windows.Application;
namespace VIZ.FGOUT.Module
......@@ -540,28 +541,31 @@ namespace VIZ.FGOUT.Module
{
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(NDIViewKeys.CAM_1);
if (manager == null) return;
var number = ApplicationDomainEx.LiteDbContext.ViewConfig.FindOne(p => p.ViewKey == NDIViewKeys.CAM_1)
.GameName;
if (!string.IsNullOrEmpty(number))
{
var config = ApplicationDomainEx.LiteDbContext.JavelinThrowConfig.FindOne(p => p.Number == number);
if (config == null) return;
//拿出来,更新修改数据
//拿出来,修改数据
var alPackage = (AlgorithmPackage_Figout_sports_model)JsonConvert.DeserializeObject(config.AlgorithmData, typeof(AlgorithmPackage_Figout_sports_model));
if (alPackage == null) return;
if (IsIntervalPixel)
{
alPackage.Matting_interval = 0;
}
else
{
alPackage.Matting_interval = Matting_interval;
}
alPackage.Matting_interval = Matting_interval;
alPackage.Moving_pixel = Moving_pixel;
alPackage.Remove_out_point_pixel = Remove_out_point_pixel;
alPackage.Is_Keep_highest = IsKeepHighest;
alPackage.Is_Big_Model = IsBigModel;
//再放回数据库
var algorithmMessage = JsonConvert.SerializeObject(alPackage, JSON_SERIALIZER_SETTINGS);
config.AlgorithmData = algorithmMessage;
ApplicationDomainEx.LiteDbContext.JavelinThrowConfig.Upsert(config);
if (IsIntervalPixel)
{
alPackage.Matting_interval = 0;
}
//发送给算法
manager.SendJson(alPackage);
......@@ -572,18 +576,6 @@ namespace VIZ.FGOUT.Module
MessageBoxEx.ShowDialog("算法参数保存成功。");
});
}
////如果IsIntervalPixel,把_temp_Matting_interval赋值给Matting_interval
//if (IsIntervalPixel)
//{
// alPackage.Matting_interval = _temp_Matting_interval;
//}
alPackage.Matting_interval = Matting_interval;
//再放回去
var algorithmMessage = JsonConvert.SerializeObject(alPackage, JSON_SERIALIZER_SETTINGS);
config.AlgorithmData = algorithmMessage;
ApplicationDomainEx.LiteDbContext.JavelinThrowConfig.Upsert(config);
}
}
......@@ -1756,12 +1748,16 @@ namespace VIZ.FGOUT.Module
private void NotCut()
{
// 发送UDP命令给音视频
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(NDIViewKeys.CAM_1__CLIP);
var manager = ConnectionManager.UdpConnection.GetEndpointManager(NDIViewKeys.CAM_1__CLIP);
if (manager == null) return;
CutPackage package = new CutPackage() { point = new int[] { 0, 0 },width = 3840, height = 2160, type = ClipPackageSignal.CUT };
// 视频的宽度和高度
var resWith = ApplicationDomain.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_WIDTH);
var resHeight = ApplicationDomain.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_HEIGHT);
var package = new CutPackage() { point = new int[] { 0, 0 },width = resWith, height = resHeight, type = ClipPackageSignal.CUT };
manager.SendJson(package);
WPFHelper.BeginInvoke(() => { MessageBoxEx.ShowDialog("取消裁切发送成功。"); });
//WPFHelper.BeginInvoke(() => { MessageBoxEx.ShowDialog("取消裁切发送成功。"); });
}
#endregion
......
......@@ -344,45 +344,46 @@ namespace VIZ.FGOUT.Module
// }
//}
//裁切
if (vm.IsSelected)
{
if (rectSelected.Width > 320 && rectSelected.Height > 180)
{
Path tempPath = new Path();
foreach (UIElement uec in canvas1.Children)
{
var path = uec as Path;
if (path?.Stroke == Brushes.Yellow)
{
tempPath = path;
}
}
canvas1.Children.Remove(tempPath);
////1
////裁切
//if (vm.IsSelected)
//{
// if (rectSelected.Width > 320 && rectSelected.Height > 180)
// {
// Path tempPath = new Path();
// foreach (UIElement uec in canvas1.Children)
// {
// var path = uec as Path;
// if (path?.Stroke == Brushes.Yellow)
// {
// tempPath = path;
// }
// }
// canvas1.Children.Remove(tempPath);
//16:9
rectSelected.Height = rectSelected.Width * 9 / 16;
//高度出画面的情况
if (rectSelected.TopLeft.Y + rectSelected.Height > this.video.Height)
{
//先算出高,再反算出宽
rectSelected.Height = this.video.Height - rectSelected.TopLeft.Y - 6;
rectSelected.Width = rectSelected.Height * 16 / 9;
}
// //16:9
// rectSelected.Height = rectSelected.Width * 9 / 16;
// //高度出画面的情况
// if (rectSelected.TopLeft.Y + rectSelected.Height > this.video.Height)
// {
// //先算出高,再反算出宽
// rectSelected.Height = this.video.Height - rectSelected.TopLeft.Y - 6;
// rectSelected.Width = rectSelected.Height * 16 / 9;
// }
aa = new PathGeometry();
aa.AddGeometry(new RectangleGeometry(rectSelected));
// aa = new PathGeometry();
// aa.AddGeometry(new RectangleGeometry(rectSelected));
var myPath = new Path()
{
Fill = Brushes.Transparent,
Stroke = Brushes.Yellow,
StrokeThickness = 1,
Data = aa
};
this.canvas1.Children.Add(myPath);
}
}
// var myPath = new Path()
// {
// Fill = Brushes.Transparent,
// Stroke = Brushes.Yellow,
// StrokeThickness = 1,
// Data = aa
// };
// this.canvas1.Children.Add(myPath);
// }
//}
if (vm.IsReplay)
{
......@@ -452,7 +453,8 @@ namespace VIZ.FGOUT.Module
var y = Convert.ToInt32(startPoint.Y / xy);
//最小距离
double minDistance = 3840;
//double minDistance = 3840;
double minDistance = 816;
if (vm.IsStartValue)
{
saveInfo = new TrackingBoxInfo();
......@@ -682,36 +684,36 @@ namespace VIZ.FGOUT.Module
{
var currentPoint = e.GetPosition(this.canvas1);
//1
//rectSelected = new Rect(startPoint, e.GetPosition(this.canvas1));
rectSelected = new Rect(startPoint, currentPoint);
////1
////rectSelected = new Rect(startPoint, e.GetPosition(this.canvas1));
//rectSelected = new Rect(startPoint, currentPoint);
////2
//var startX = startPoint.X;
//var startY = startPoint.Y;
//double width = Math.Abs(currentPoint.X - startX);
//double height = width * 9 / 16;
//var rg = new RectangleGeometry
//{
// Rect = new Rect(startX, startY, width, height)
//};
//2
var startX = startPoint.X;
var startY = startPoint.Y;
var width = Math.Abs(currentPoint.X - startX);
var height = width * 9 / 16;
var rg = new RectangleGeometry
{
Rect = new Rect(startX, startY, width, height)
};
//rectSelected = new Rect(startPoint, currentPoint);
rectSelected = new Rect(startPoint, currentPoint);
//if (_currMarkPath == null)
//{
// _currMarkPath = new Path
// {
// Stroke = Brushes.Yellow,
// StrokeThickness = 1,
// Data = rg
// };
// this.canvas1.Children.Add(_currMarkPath);
//}
//else
//{
// _currMarkPath.Data = rg;
//}
if (_currMarkPath == null)
{
_currMarkPath = new Path
{
Stroke = Brushes.Yellow,
StrokeThickness = 1,
Data = rg
};
this.canvas1.Children.Add(_currMarkPath);
}
else
{
_currMarkPath.Data = rg;
}
}
}
}
......
......@@ -298,6 +298,8 @@ namespace VIZ.FGOUT.Module
//清除点选跟踪框的数据
NDIView.saveInfos = new List<TrackingBoxInfo>();
//清除拖框入点的数据
NDIView.rectsReplay.Clear();
}
else if (view.vm.IsEndValue)
{
......@@ -309,12 +311,10 @@ namespace VIZ.FGOUT.Module
//清除点选跟踪框的数据
NDIView.saveOutPointInfos = new List<TrackingBoxInfo>();
//清除拖框出点的数据
NDIView.rectsOutReplay.Clear();
}
}
////清除点选跟踪框的数据
//NDIView.saveInfos = new List<TrackingBoxInfo>();
//NDIView.saveOutPointInfos = new List<TrackingBoxInfo>();
}
else
{
......@@ -329,8 +329,10 @@ namespace VIZ.FGOUT.Module
_RecordStartTime = info2.TimeCode;
_singleInfo = info2;
//清除点选跟踪框的数据
//清除点选入点跟踪框的数据
NDIView.saveInfo = new TrackingBoxInfo();
//清除拖框入点的数据
NDIView.rectsReplay.Clear();
}
else if (view.vm.IsEndValue)
{
......@@ -340,19 +342,12 @@ namespace VIZ.FGOUT.Module
_RecordEndTime = info2.TimeCode;
_singleOutPointInfo = info2;
//清除点选跟踪框的数据
//清除点选出点跟踪框的数据
NDIView.saveOutPointInfo = new TrackingBoxInfo();
//清除拖框出点的数据
NDIView.rectsOutReplay.Clear();
}
}
////清除点选跟踪框的数据
//NDIView.saveInfo = new TrackingBoxInfo();
//NDIView.saveOutPointInfo = new TrackingBoxInfo();
//清除拖框的数据
NDIView.rectsReplay.Clear();
NDIView.rectsOutReplay.Clear();
}
}
......@@ -386,53 +381,64 @@ namespace VIZ.FGOUT.Module
gameName.Equals(SportsProjectCodes.ST) ||
gameName.Equals(SportsProjectCodes.SP))
{
foreach (var saveInfo in NDIView.saveInfos)
{
//更新红色点中框
if (saveInfo.SrcRect.Left > 0)
//if (view.vm.IsStartValue)
//{
foreach (var saveInfo in NDIView.saveInfos)
{
saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(saveInfo);
//记录标红框时入点时间戳
_RecordStartTime = saveInfo.TimeCode;
//更新红色点中框
if (saveInfo.SrcRect.Left > 0)
{
saveInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(saveInfo);
//记录标红框时入点时间戳
_RecordStartTime = saveInfo.TimeCode;
}
}
}
foreach (var saveOutInfo in NDIView.saveOutPointInfos)
{
//更新绿色点中框
if (saveOutInfo.SrcRect.Left > 0)
//}
//else if (view.vm.IsEndValue)
//{
foreach (var saveOutInfo in NDIView.saveOutPointInfos)
{
saveOutInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR_GREEN;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(saveOutInfo);
//记录标红框时出点时间戳
_RecordEndTime = saveOutInfo.TimeCode;
//更新绿色点中框
if (saveOutInfo.SrcRect.Left > 0)
{
saveOutInfo.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR_GREEN;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(saveOutInfo);
//记录标红框时出点时间戳
_RecordEndTime = saveOutInfo.TimeCode;
}
}
}
//}
}
else
{
//单人
//更新红色点中框
var info = NDIView.saveInfo;
var infoOut = NDIView.saveOutPointInfo;
if (info.SrcRect.Left > 0)
{
info.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(info);
//记录标红框时入点时间戳
_RecordStartTime = info.TimeCode;
}
if (infoOut.SrcRect.Left > 0)
{
infoOut.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR_GREEN;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(infoOut);
//记录标绿框时入点时间戳
_RecordEndTime = infoOut.TimeCode;
}
//if (view.vm.IsStartValue)
//{
var info = NDIView.saveInfo;
if (info.SrcRect.Left > 0)
{
info.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(info);
//记录标红框时入点时间戳
_RecordStartTime = info.TimeCode;
}
//}
//else if (view.vm.IsEndValue)
//{
var infoOut = NDIView.saveOutPointInfo;
if (infoOut.SrcRect.Left > 0)
{
infoOut.DrawingBorderColor = this.TRACKING_BOX_BORDER_COLOR_GREEN;
//把选中框的信息也加到这个集合里
_cam3Infos.Add(infoOut);
//记录标绿框时入点时间戳
_RecordEndTime = infoOut.TimeCode;
}
//}
}
//再更新跟踪框信息
view3.video.UpdateTrackingBox(_cam3Infos);
......
......@@ -216,6 +216,7 @@ namespace VIZ.FGOUT.Module
ApplicationDomain.MessageManager.Register<SendSelectedModel>(this, this.SendSelected);
}
private CutPackage _package;
/// <summary>
/// 发送裁切框数据
/// </summary>
......@@ -238,8 +239,14 @@ namespace VIZ.FGOUT.Module
CutPackage package = Coordinate(rect, srcWidth, srcHeight);
package.type = ClipPackageSignal.CUT;
//if (_package != null && _package.point[0] == package.point[0] && _package.point[1] == package.point[1] && _package.width == package.width && _package.height == package.height)
//{
// return;
//}
//_package = package;
manager.SendJson(package);
WPFHelper.BeginInvoke(() => { MessageBoxEx.ShowDialog("裁切框发送成功。"); });
//WPFHelper.BeginInvoke(() => { MessageBoxEx.ShowDialog("裁切框发送成功。"); });
}
}
......@@ -271,6 +278,8 @@ namespace VIZ.FGOUT.Module
nDIView.rectSelected = new Rect();
nDIView._currMarkPath = null;
}
_package = null;
}
}
......@@ -1177,9 +1186,8 @@ namespace VIZ.FGOUT.Module
private List<List<List<int>>> Coordinate(List<System.Windows.Rect> rects, double srcWidth, double srcHeight)
{
// 视频的宽度
// 视频的宽度和高度
int resWith = ApplicationDomain.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_WIDTH);
// 视频的高度
int resHeight = ApplicationDomain.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_HEIGHT);
double xp = srcWidth / resWith;
......@@ -1210,23 +1218,22 @@ namespace VIZ.FGOUT.Module
private CutPackage Coordinate(Rect rect, double srcWidth, double srcHeight)
{
// 视频的宽度
int resWith = ApplicationDomain.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_WIDTH);
// 视频的高度
int resHeight = ApplicationDomain.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_HEIGHT);
// 视频的宽度和高度
var resWith = ApplicationDomain.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_WIDTH);
var resHeight = ApplicationDomain.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_HEIGHT);
double xp = srcWidth / resWith;
double xy = srcHeight / resHeight;
var xp = srcWidth / resWith;
var xy = srcHeight / resHeight;
int dx = Convert.ToInt32(rect.X / xp);
int dy = Convert.ToInt32(rect.Y / xy);
var dx = Convert.ToInt32(rect.X / xp);
var dy = Convert.ToInt32(rect.Y / xy);
int width = Convert.ToInt32(rect.Width / xp);
var width = Convert.ToInt32(rect.Width / xp);
if (width + dx > resWith)
{
width = resWith - dx;
}
int height = Convert.ToInt32(width * 9 / 16);
var height = Convert.ToInt32(width * 9 / 16);
//int height2 = Convert.ToInt32(rect.Height / xy);
if (height + dy > resHeight)
{
......

C:\Projects\FGOUT\VIZ.FGOUT\VIZ.FGOUT.Module\obj\x64\Debug\GeneratedInternalTypeHelper.g.cs
FC:\Projects\FGOUT\VIZ.FGOUT\VIZ.FGOUT.Module\NDIMainView\View\NDIMainView.xaml;;
FC:\Projects\FGOUT\VIZ.FGOUT\VIZ.FGOUT.Module\NDIPreviewView\View\NDIPreviewView.xaml;;
......
......@@ -55,5 +55,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.20.0")]
[assembly: AssemblyFileVersion("1.0.20.0")]
[assembly: AssemblyVersion("1.0.22.0")]
[assembly: AssemblyFileVersion("1.0.22.0")]
......@@ -86,7 +86,7 @@ UDP_UESETTING_PORT=8888
;UDP算法端口
UDP_Algorithm_PORT=8001
;UDP音视频流IP, 如果该值不配置,那么会从流中获取
;UDP_Stream_IP=192.168.31.83
UDP_Stream_IP=192.168.31.83
; ============================================================
; === Algorithm ===
; ============================================================
......
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