Commit 9b559226 by 鲁志-悦动

裁切框发送逻辑

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