Commit 9b559226 by 鲁志-悦动

裁切框发送逻辑

parent dc7c63ee
......@@ -26,5 +26,10 @@
/// 通知UI界面贴图状态
/// </summary>
public const string MaskMsg = "MaskMsg";
/// <summary>
/// 裁切
/// </summary>
public const string CUT = "CUT";
}
}
using System.Windows;
namespace VIZ.FGOUT.Connection
{
public class CutPackage
{
/// <summary>
/// 类型
/// </summary>
public string type { get; set; }
public Point point { get; set; }
/// <summary>
/// 宽度
/// </summary>
public int width { get; set; }
/// <summary>
/// 高度
/// </summary>
public int height { get; set; }
}
}
......@@ -69,6 +69,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
......@@ -109,6 +110,7 @@
<Compile Include="UDP\Clip\Signal\Recv\ClipRecvPackage__MaskMsg.cs" />
<Compile Include="UDP\Clip\Signal\Recv\ClipRecvPackage__ReplayResp.cs" />
<Compile Include="UDP\Clip\Signal\Send\ClipPackage__crop_roi.cs" />
<Compile Include="UDP\Clip\Signal\Send\CutPackage.cs" />
<Compile Include="UDP\Clip\Signal\Send\ReconfirmPackage.cs" />
<Compile Include="UDP\Clip\Signal\Send\ReplayPackage.cs" />
<Compile Include="UDP\Clip\Signal\Send\SaveMatImagePackage.cs" />
......
f04930f7d024d366b65c16faf728efd9669a1c905de8a5b7b1939c35c71db852
fdb17c9cbb423f79e69f8ee66f5a678e13d013d039a83615c37adfa96664664b
namespace VIZ.FGOUT.Domain
{
public class SendSelectedModel
{
}
}
......@@ -107,6 +107,7 @@
<Compile Include="Message\Setting\SavePlaceModel.cs" />
<Compile Include="Message\Setting\SelectedModel.cs" />
<Compile Include="Message\Setting\SendPlaceModel.cs" />
<Compile Include="Message\Setting\SendSelectedModel.cs" />
<Compile Include="Message\Setting\ShowInvalidPlaceModel.cs" />
<Compile Include="Message\Setting\StartPlaceModel.cs" />
<Compile Include="Message\Setting\StopAlgorithmModel.cs" />
......
2f14f2db1b01881eda563500b12f9256867d2957342ab955e6ef57d67fe5881a
6dbbb496131483f6805b920d58656b9902d6ac9fddf9b32af7a01fa30efc73d7
......@@ -1143,7 +1143,7 @@
Height="40"
HorizontalAlignment="Center"
Command="{Binding Path=SelectedCommand}"
Content="选择"
Content="拖框"
IsChecked="{Binding SelectedIsChecked, Mode=TwoWay}"
Style="{StaticResource ToggleButtonStyle}" />
<Button
......@@ -1151,7 +1151,7 @@
Width="100"
Height="40"
HorizontalAlignment="Center"
Command="{Binding Path=Command}"
Command="{Binding Path=SendSelectedCommand}"
Content="{DynamicResource Send}"
Style="{StaticResource ButtonStyle}" />
</Grid>
......
......@@ -222,6 +222,7 @@ namespace VIZ.FGOUT.Module
//裁切区域
this.SelectedCommand = new VCommand(this.Selected);
this.SendSelectedCommand = new VCommand(this.SendSelected);
}
/// <summary>
......@@ -1535,7 +1536,6 @@ namespace VIZ.FGOUT.Module
// 发送UDP命令给音视频
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(NDIViewKeys.CAM_1__CLIP);
if (manager == null) return;
manager.SendJson(package);
}
......@@ -1614,6 +1614,9 @@ namespace VIZ.FGOUT.Module
}
SelectedModel _selectedModel = new SelectedModel();
/// <summary>
/// 拖框开关
/// </summary>
public VCommand SelectedCommand { get; set; }
private void Selected()
......@@ -1629,6 +1632,17 @@ namespace VIZ.FGOUT.Module
ApplicationDomain.MessageManager.Send(_selectedModel);
}
SendSelectedModel _sendSelectedModel = new SendSelectedModel();
/// <summary>
/// 发送拖框数据
/// </summary>
public VCommand SendSelectedCommand { get; set; }
private void SendSelected()
{
ApplicationDomain.MessageManager.Send(_sendSelectedModel);
}
#endregion
#region Live
......
......@@ -347,31 +347,32 @@ namespace VIZ.FGOUT.Module
//裁切
if (vm.IsSelected)
{
Path tempPath = new Path();
foreach (UIElement uec in canvas1.Children)
if (rectSelected.Width > 300 && rectSelected.Height > 150)
{
var path = uec as Path;
if (path?.Stroke == Brushes.Yellow)
Path tempPath = new Path();
foreach (UIElement uec in canvas1.Children)
{
tempPath = path;
var path = uec as Path;
if (path?.Stroke == Brushes.Yellow)
{
tempPath = path;
}
}
}
canvas1.Children.Remove(tempPath);
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);
canvas1.Children.Remove(tempPath);
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);
}
//aa = new PathGeometry();
//aa.AddGeometry(new RectangleGeometry(rectSelected));
}
//myPath.Data = aa;
......@@ -654,7 +655,7 @@ namespace VIZ.FGOUT.Module
// rectInvalid = new Rect(startPoint, e.GetPosition(this.canvas1));
//}
if (vm.IsReplay)
if (vm.IsReplay && this.NDIKey == NDIViewKeys.CAM_3)
{
if (vm.IsStartValue)
{
......@@ -668,7 +669,7 @@ namespace VIZ.FGOUT.Module
}
//裁切
if (vm.IsSelected)
if (vm.IsSelected && this.NDIKey == NDIViewKeys.CAM_1)
{
rectSelected = new Rect(startPoint, e.GetPosition(this.canvas1));
}
......
using log4net;
using SharpDX;
using SharpDX.Mathematics.Interop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
......@@ -215,6 +213,35 @@ namespace VIZ.FGOUT.Module
//裁切区域发送命令
ApplicationDomain.MessageManager.Register<SelectedModel>(this, this.Selected);
ApplicationDomain.MessageManager.Register<SendSelectedModel>(this, this.SendSelected);
}
/// <summary>
/// 发送裁切框数据
/// </summary>
/// <param name="sendSelectedModel"></param>
private void SendSelected(SendSelectedModel sendSelectedModel)
{
if (this.ViewKey != NDIViewKeys.CAM_1) return;
NDIView nDIView = this.GetView<NDIView>();
var rect = nDIView.rectSelected;
if (rect != null && rect.Width > 0)
{
// 发送UDP命令给音视频
UdpEndpointManager manager = ConnectionManager.UdpConnection.GetEndpointManager(NDIViewKeys.CAM_1__CLIP);
if (manager == null) return;
var srcWidth = nDIView.video.ActualWidth;
var srcHeight = nDIView.video.ActualHeight;
CutPackage package = Coordinate(rect, srcWidth, srcHeight);
package.type = ClipPackageSignal.CUT;
manager.SendJson(package);
WPFHelper.BeginInvoke(() => { MessageBoxEx.ShowDialog("裁切框发送成功。"); });
}
}
public bool IsSelected;
......@@ -223,6 +250,26 @@ namespace VIZ.FGOUT.Module
//if (this.ViewKey == NDIViewKeys.CAM_2 || this.ViewKey == NDIViewKeys.CAM_4) return;
if (this.ViewKey != NDIViewKeys.CAM_1) return;
IsSelected = selectedModel.IsSelected;
if (!IsSelected)
{
NDIView nDIView = this.GetView<NDIView>();
var rect = nDIView.rectSelected;
if (rect.Width > 0)
{
Path tempPath = new Path();
foreach (UIElement uec in nDIView.canvas1.Children)
{
var path = uec as Path;
if (path?.Stroke == Brushes.Yellow)
{
tempPath = path;
}
}
nDIView.canvas1.Children.Remove(tempPath);
nDIView.rectSelected = new Rect();
}
}
}
private void ReplayOutPort(ReplayOutPointModel replayOutPointModel)
......@@ -949,8 +996,7 @@ namespace VIZ.FGOUT.Module
public bool IsCleanPlace;
private void CleanPlace(CleanPlaceModel cleanPlaceModel)
{
if (this.ViewKey != NDIViewKeys.CAM_1)
return;
if (this.ViewKey != NDIViewKeys.CAM_1) return;
if (!cleanPlaceModel.IsRefreshPosition)
{
......@@ -959,8 +1005,8 @@ namespace VIZ.FGOUT.Module
}
var ndiView = this.GetView<NDIView>();
if (ndiView == null)
return;
if (ndiView == null) return;
IsCleanPlace = cleanPlaceModel.CleanPlace;
IsDrawStartPlace = false;
......@@ -973,6 +1019,8 @@ namespace VIZ.FGOUT.Module
ndiView.canvas1.Children.Clear();
ndiView.polygon = null;
ndiView.rectSelected = new Rect();
}
private void ShowInvalidPlace(ShowInvalidPlaceModel showInvalidPlaceModel)
......@@ -992,6 +1040,8 @@ namespace VIZ.FGOUT.Module
ndiView.canvas1.Children.Clear();
ndiView.polygon = null;
ndiView.rectSelected = new Rect();
var setPlaceNewConfig = ApplicationDomainEx.LiteDbContext.SetPlaceNewConfig.FindOne(p =>
p.SportCode == this.viewConfig.GameName);
if (setPlaceNewConfig == null) return;
......@@ -1011,7 +1061,6 @@ namespace VIZ.FGOUT.Module
private void SaveAndSendPlace(SendPlaceModel sendPlaceModel)
{
if (this.ViewKey != NDIViewKeys.CAM_1) return;
NDIView nDIView = this.GetView<NDIView>();
//自动模式下验证开始、结束标记
......@@ -1032,7 +1081,7 @@ namespace VIZ.FGOUT.Module
{
MessageBoxEx.ShowDialog("开始标记没有数据," + message);
});
return;
return;
}
}
......@@ -1154,6 +1203,23 @@ namespace VIZ.FGOUT.Module
return listOuterMost;
}
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);
double xp = srcWidth / resWith;
double xy = srcHeight / resHeight;
int dx = Convert.ToInt32(rect.X / xp);
int dy = Convert.ToInt32(rect.Y / xy);
int width = Convert.ToInt32(rect.Width / xp);
return new CutPackage() { point = new Point(dx, dy), width = width, height = Convert.ToInt32(width * 9 / 16) };
}
private List<List<List<int>>> CoordinateTrackingBoxInfo(RawRectangleF rect, double srcWidth, double srcHeight)
{
var listOuterMost = new List<List<List<int>>>();
......
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "50A104AF79A5D20E9C306E99391E80B56F06BC7FC2C026131FA83FAF45D13A4F"
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "DB3E8891C6259C7E7B14BEEC7B2210E24DEC5152955F643723E8CFFFEC460892"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
......
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "50A104AF79A5D20E9C306E99391E80B56F06BC7FC2C026131FA83FAF45D13A4F"
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "DB3E8891C6259C7E7B14BEEC7B2210E24DEC5152955F643723E8CFFFEC460892"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
......
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