Commit 6a4f1e1c by liulongfei

消息接入

parent 56588334
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.ElectricRabbit.Connection
{
/// <summary>
/// 算法数据包基类
/// </summary>
public class AlgorithmPackageBase
{
/// <summary>
/// 信号
/// <see cref="AlgorithmPackageSignal"/>
/// </summary>
public virtual string signal { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;
using VIZ.Framework.Connection;
namespace VIZ.ElectricRabbit.Connection
{
/// <summary>
/// 算法单条消息为json的解析器
/// </summary>
public class AlgorithmPackageProvider : ConnSingleJsonPackageProvider
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AlgorithmPackageProvider));
public AlgorithmPackageProvider()
{
// 算法检测
this.providers.Add(new AlgorithmProvider__detect());
}
/// <summary>
/// 算法数据包处理器
/// </summary>
private List<IAlgorithmPackageProvider> providers = new List<IAlgorithmPackageProvider>();
/// <summary>
/// 执行
/// </summary>
/// <param name="info">信息</param>
protected override void Execute(ConnSingleJsonInfo info)
{
Task.Run(() =>
{
try
{
AlgorithmPackageBase @base = Newtonsoft.Json.JsonConvert.DeserializeObject<AlgorithmPackageBase>(info.Json);
foreach (IAlgorithmPackageProvider provider in this.providers)
{
if (string.Equals(provider.Signal, @base.signal))
{
provider.Execute(info);
break;
}
}
}
catch (Exception ex)
{
log.Error(ex);
}
});
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.ElectricRabbit.Connection
{
/// <summary>
/// 算法数据包信号
/// </summary>
public static class AlgorithmPackageSignal
{
// ----------------------------------------------------------------
// 接收
/// <summary>
/// 检测
/// </summary>
public const string detect = "detect";
// ----------------------------------------------------------------
// 发送
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Framework.Connection;
namespace VIZ.ElectricRabbit.Connection
{
/// <summary>
/// 算法包解析器
/// </summary>
public interface IAlgorithmPackageProvider
{
/// <summary>
/// 信号
/// <see cref="AlgorithmPackageSignal"/>
/// </summary>
string Signal { get; }
/// <summary>
/// 执行
/// </summary>
/// <param name="info">信息</param>
void Execute(ConnSingleJsonInfo info);
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Framework.Connection;
using VIZ.ElectricRabbit.Domain;
namespace VIZ.ElectricRabbit.Connection
{
/// <summary>
/// 算法解释器 -- 目标检测
/// </summary>
public class AlgorithmProvider__detect : IAlgorithmPackageProvider
{
/// <summary>
/// 信号
/// <see cref="AlgorithmPackageSignal"/>
/// </summary>
public string Signal { get; } = AlgorithmPackageSignal.detect;
/// <summary>
/// 执行
/// </summary>
/// <param name="info">信息</param>
public void Execute(ConnSingleJsonInfo info)
{
AlgorithmRecvPackage__detect package = Newtonsoft.Json.JsonConvert.DeserializeObject<AlgorithmRecvPackage__detect>(info.Json);
AlgorithmDectectMessage msg = new AlgorithmDectectMessage();
msg.target_bbox = package.target_bbox;
ApplicationDomainEx.MessageManager.Send(msg);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.ElectricRabbit.Connection
{
/// <summary>
/// 算法数据包 -- 检测
/// </summary>
public class AlgorithmRecvPackage__detect : AlgorithmPackageBase
{
/// <summary>
/// 信号
/// <see cref="AlgorithmPackageSignal"/>
/// </summary>
public override string signal { get; set; } = AlgorithmPackageSignal.detect;
/// <summary>
/// 目标框(左上角x,y,右下角x,y)
/// </summary>
public List<int> target_bbox { get; set; }
}
}
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
...@@ -65,6 +68,12 @@ ...@@ -65,6 +68,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UDP\Algorithm\AlgorithmPackageBase.cs" />
<Compile Include="UDP\Algorithm\AlgorithmPackageProvider.cs" />
<Compile Include="UDP\Algorithm\Enum\AlgorithmPackageSignal.cs" />
<Compile Include="UDP\Algorithm\IAlgorithmPackageProvider.cs" />
<Compile Include="UDP\Algorithm\Provider\AlgorithmProvider__detect.cs" />
<Compile Include="UDP\Algorithm\Signal\Recv\AlgorithmRecvPackage__detect.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Connection\VIZ.Framework.Connection.csproj"> <ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Connection\VIZ.Framework.Connection.csproj">
...@@ -99,5 +108,10 @@ ...@@ -99,5 +108,10 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="UDP\Algorithm\Info\" />
<Folder Include="UDP\Algorithm\Sender\" />
<Folder Include="UDP\Algorithm\Signal\Send\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.14" targetFramework="net48" /> <package id="log4net" version="2.0.14" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
</packages> </packages>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.ElectricRabbit.Domain
{
/// <summary>
/// 算法检测消息
/// </summary>
public class AlgorithmDectectMessage
{
/// <summary>
/// 目标框
/// </summary>
public List<int> target_bbox { get; set; }
}
}
...@@ -70,7 +70,9 @@ ...@@ -70,7 +70,9 @@
<Compile Include="ApplicationConstant.cs" /> <Compile Include="ApplicationConstant.cs" />
<Compile Include="ApplicationDomainEx.cs" /> <Compile Include="ApplicationDomainEx.cs" />
<Compile Include="Info\ClientConfigInfo.cs" /> <Compile Include="Info\ClientConfigInfo.cs" />
<Compile Include="Message\Algorithm\AlgorithmDectectMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VideoViewKeys.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Core\VIZ.Framework.Core.csproj"> <ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Core\VIZ.Framework.Core.csproj">
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.ElectricRabbit.Domain
{
/// <summary>
/// 视频视图键
/// </summary>
public static class VideoViewKeys
{
/// <summary>
/// 主视图
/// </summary>
public const string Main = "Main";
}
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:VIZ.ElectricRabbit.Module" xmlns:local="clr-namespace:VIZ.ElectricRabbit.Module"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common" xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core" xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
...@@ -24,6 +25,12 @@ ...@@ -24,6 +25,12 @@
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Loaded">
<behaviors:InvokeCommandAction Command="{Binding LoadedCommand}" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition> <RowDefinition Height="30"></RowDefinition>
...@@ -57,14 +64,14 @@ ...@@ -57,14 +64,14 @@
<common:ArrowShape ArrowMaxHeight="120" ArrowMaxWidth="120" ArrowMinHeigh="60" ArrowMinWidth="60" <common:ArrowShape ArrowMaxHeight="120" ArrowMaxWidth="120" ArrowMinHeigh="60" ArrowMinWidth="60"
RectangleMaxHeigh="40" RectangleMaxWidth="1200" RectangleMinHeigh="5" RectangleMinWidth="20" RectangleMaxHeigh="40" RectangleMaxWidth="1200" RectangleMinHeigh="5" RectangleMinWidth="20"
SafeRectangleWidth="400" RectangleHeightProportion="0.4" SafeRectangleWidth="400" RectangleHeightProportion="0.4"
DifferenceSafeValue="20" DifferenceMaxValue="100" DifferenceSafeValue="{Binding SettingViewModel.SafeDistance}" DifferenceMaxValue="1920"
DifferenceValue="{Binding ElementName=slider,Path=Value,Mode=OneWay}" DifferenceValue="{Binding DifferenceValue,Mode=OneWay}"
LeftBrush="#066FA5" RightBrush="#F70044" SafeBrush="#11CD86"></common:ArrowShape> LeftBrush="#066FA5" RightBrush="#F70044" SafeBrush="#11CD86"></common:ArrowShape>
</fcommon:FlashingBorder> </fcommon:FlashingBorder>
<Slider VerticalAlignment="Center" Width="200" Minimum="-100" Maximum="100" <!--<Slider VerticalAlignment="Center" Width="200" Minimum="-100" Maximum="100"
x:Name="slider" Value="0" Grid.ColumnSpan="2" HorizontalAlignment="Right"></Slider> x:Name="slider" Value="0" Grid.ColumnSpan="2" HorizontalAlignment="Right"></Slider>-->
<!-- 主视频区域 --> <!-- 主视频区域 -->
<fcommon:VideoControl Grid.Row="1" Margin="10,0,44,0"></fcommon:VideoControl> <fcommon:VideoControl x:Name="video" Grid.Row="1" Margin="10,0,44,0"></fcommon:VideoControl>
<CheckBox x:Name="cbShowSettingView" Grid.Row="1" Style="{StaticResource CheckBox_Expand}" <CheckBox x:Name="cbShowSettingView" Grid.Row="1" Style="{StaticResource CheckBox_Expand}"
HorizontalAlignment="Right" VerticalAlignment="Stretch" Margin="0,0,10,0" HorizontalAlignment="Right" VerticalAlignment="Stretch" Margin="0,0,10,0"
IsChecked="{Binding Path=IsShowSettingView,Mode=TwoWay}"></CheckBox> IsChecked="{Binding Path=IsShowSettingView,Mode=TwoWay}"></CheckBox>
......
...@@ -5,6 +5,7 @@ using System.Text; ...@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Shapes; using System.Windows.Shapes;
using VIZ.ElectricRabbit.Domain;
using VIZ.Framework.Common; using VIZ.Framework.Common;
using VIZ.Framework.Core; using VIZ.Framework.Core;
...@@ -19,6 +20,9 @@ namespace VIZ.ElectricRabbit.Module ...@@ -19,6 +20,9 @@ namespace VIZ.ElectricRabbit.Module
{ {
// 初始化命令 // 初始化命令
this.InitCommand(); this.InitCommand();
// 初始化消息
this.InitMessage();
} }
/// <summary> /// <summary>
...@@ -29,6 +33,15 @@ namespace VIZ.ElectricRabbit.Module ...@@ -29,6 +33,15 @@ namespace VIZ.ElectricRabbit.Module
this.SettingCommand = new VCommand(this.Setting); this.SettingCommand = new VCommand(this.Setting);
this.MinCommand = new VCommand(this.Min); this.MinCommand = new VCommand(this.Min);
this.CloseCommand = new VCommand(this.Close); this.CloseCommand = new VCommand(this.Close);
this.LoadedCommand = new VCommand(this.Loaded);
}
/// <summary>
/// 初始化消息
/// </summary>
private void InitMessage()
{
ApplicationDomainEx.MessageManager.Register<AlgorithmDectectMessage>(this, this.OnAlgorithmDectectMessage);
} }
// ================================================================================ // ================================================================================
...@@ -63,10 +76,97 @@ namespace VIZ.ElectricRabbit.Module ...@@ -63,10 +76,97 @@ namespace VIZ.ElectricRabbit.Module
#endregion #endregion
#region DifferenceValue -- 目标框与中心轴的差值
private double differenceValue;
/// <summary>
/// 目标框与中心轴的差值
/// </summary>
public double DifferenceValue
{
get { return differenceValue; }
set { differenceValue = value; this.RaisePropertySaveChanged(nameof(DifferenceValue)); }
}
#endregion
// ================================================================================ // ================================================================================
// Command // Command
// ================================================================================ // ================================================================================
#region LoadedCommand -- 加载完成命令
/// <summary>
/// 加载完成命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载完成
/// </summary>
private void Loaded()
{
// 初始化视频控件
this.InitVideoControl();
// 初始化OpenCV流
this.InitOpenCvStream();
}
/// <summary>
/// 初始化视频控件
/// </summary>
private void InitVideoControl()
{
MainView view = this.GetView<MainView>();
if (view == null)
return;
// 调试模式下显示FPS
view.video.IsShowFPS = ApplicationDomainEx.IS_DEBUG;
// 跟踪框插件
TrackingBoxPlugin trackingBoxPlugin = new TrackingBoxPlugin(view.video);
view.video.AttachPlugin(trackingBoxPlugin);
// 安全轴插件
CenterAxisPlugin centerAxisPlugin = new CenterAxisPlugin(view.video);
view.video.AttachPlugin(centerAxisPlugin);
}
/// <summary>
/// 初始化OpenCV流
/// </summary>
private void InitOpenCvStream()
{
OpenCVStream stream = VideoStreamManager.Get<OpenCVStream>(VideoViewKeys.Main);
stream.ExecuteVideoFrame -= Stream_ExecuteVideoFrame;
stream.ExecuteVideoFrame += Stream_ExecuteVideoFrame;
}
/// <summary>
/// 获取到视频帧时触发
/// </summary>
private void Stream_ExecuteVideoFrame(object sender, VideoFrameEventArgs e)
{
MainView view = this.GetView<MainView>();
if (view == null)
return;
// 更新视频帧
view.video.UpdateVideoFrame(e.Frame);
// 更新安全轴
CenterAxisInfo centerAxisInfo = new CenterAxisInfo();
centerAxisInfo.AxisType = CenterAxisType.Vertical;
centerAxisInfo.SrcCenter = new SharpDX.Mathematics.Interop.RawVector2(this.SettingViewModel.SafeAxis, 0);
centerAxisInfo.AxisColor = SharpDxColorHelper.FromString("#AA000000");
centerAxisInfo.AxisWidth = 2;
view.video.UpdateCenterAxis(centerAxisInfo);
}
#endregion
#region CloseCommand -- 关闭命令 #region CloseCommand -- 关闭命令
/// <summary> /// <summary>
...@@ -126,5 +226,48 @@ namespace VIZ.ElectricRabbit.Module ...@@ -126,5 +226,48 @@ namespace VIZ.ElectricRabbit.Module
#endregion #endregion
// ================================================================================
// Message
// ================================================================================
/// <summary>
/// 处理目标检测消息
/// </summary>
/// <param name="msg">消息</param>
private void OnAlgorithmDectectMessage(AlgorithmDectectMessage msg)
{
MainView view = this.GetView<MainView>();
if (view == null)
return;
// 如果没有目标框,或目标框数据不正确,那么清理目标框
if (msg.target_bbox == null || msg.target_bbox.Count != 4)
{
view.video.ClearTrackingBox();
return;
}
// 更新目标框位置
List<TrackingBoxInfo> infos = new List<TrackingBoxInfo>();
TrackingBoxInfo info = new TrackingBoxInfo();
info.DrawingBorderWidth = 2;
info.DrawingBorderColor = SharpDxColorHelper.FromString("#FFFF0000");
float left = msg.target_bbox[0];
float top = msg.target_bbox[1];
float right = msg.target_bbox[2];
float bottom = msg.target_bbox[3];
info.SrcRect = new SharpDX.Mathematics.Interop.RawRectangleF(left, top, right, bottom);
infos.Add(info);
view.video.UpdateTrackingBox(infos);
// 更新差值
double center = (right - left) / 2d;
this.DifferenceValue = this.SettingViewModel.SafeAxis - center;
}
} }
} }
...@@ -17,9 +17,10 @@ namespace VIZ.ElectricRabbit.Module ...@@ -17,9 +17,10 @@ namespace VIZ.ElectricRabbit.Module
/// 应用程序启动 -- 初始化INI /// 应用程序启动 -- 初始化INI
/// </summary> /// </summary>
public class AppSetup_InitINI : AppSetupBase public class AppSetup_InitINI : AppSetupBase
{/// <summary> {
/// 日志 /// <summary>
/// </summary> /// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AppSetup_InitINI)); private static ILog log = LogManager.GetLogger(typeof(AppSetup_InitINI));
/// <summary> /// <summary>
......
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using VIZ.ElectricRabbit.Domain;
using VIZ.ElectricRabbit.Storage;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.Framework.Domain;
using VIZ.Framework.Module;
namespace VIZ.ElectricRabbit.Module
{
/// <summary>
/// 应用程序启动 -- 初始化OpenCV
/// </summary>
public class AppSetup_InitOpenCV : AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AppSetup_InitOpenCV));
/// <summary>
/// OpenCV流索引
/// </summary>
private readonly static int CLIENT_OPEN_CV_STREAM_INDEX = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, int>(p => p.CLIENT_OPEN_CV_STREAM_INDEX);
/// <summary>
/// 描述
/// </summary>
public override string Detail { get; } = "应用程序启动 -- 初始化OpenCV";
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
/// <returns>是否成功执行</returns>
public override bool Setup(AppSetupContext context)
{
OpenCVStreamOption option = new OpenCVStreamOption();
OpenCVStream stream = new OpenCVStream(CLIENT_OPEN_CV_STREAM_INDEX, option);
VideoStreamManager.Append(VideoViewKeys.Main, stream);
Task.Run(() =>
{
stream.Start();
});
return true;
}
/// <summary>
/// 执行关闭
/// </summary>
/// <param name="context">应用程序启动上下文</param>
public override void Shutdown(AppSetupContext context)
{
OpenCVStream stream = VideoStreamManager.Get<OpenCVStream>(VideoViewKeys.Main);
stream?.Dispose();
}
}
}
\ No newline at end of file
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using VIZ.ElectricRabbit.Connection;
using VIZ.ElectricRabbit.Domain;
using VIZ.ElectricRabbit.Storage;
using VIZ.Framework.Connection;
using VIZ.Framework.Core;
using VIZ.Framework.Domain;
using VIZ.Framework.Module;
namespace VIZ.ElectricRabbit.Module
{
/// <summary>
/// 应用程序启动 -- 初始化UDP
/// </summary>
public class AppSetup_InitUDP : AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AppSetup_InitUDP));
/// <summary>
/// UDP 绑定IP
/// </summary>
private readonly static string CLIENT_UDP_BINDING_IP = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, string>(p => p.CLIENT_UDP_BINDING_IP);
/// <summary>
/// UDP 绑定端口
/// </summary>
private readonly static int CLIENT_UDP_BINDING_PORT = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, int>(p => p.CLIENT_UDP_BINDING_PORT);
/// <summary>
/// 描述
/// </summary>
public override string Detail { get; } = "应用程序启动 -- 初始化UDP";
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
/// <returns>是否成功执行</returns>
public override bool Setup(AppSetupContext context)
{
UdpConnection conn = new UdpConnection();
conn.PackageProvider = new AlgorithmPackageProvider();
conn.Binding(CLIENT_UDP_BINDING_IP, CLIENT_UDP_BINDING_PORT);
ConnectionManager.UdpConnection = conn;
conn.Start();
return true;
}
/// <summary>
/// 执行关闭
/// </summary>
/// <param name="context">应用程序启动上下文</param>
public override void Shutdown(AppSetupContext context)
{
ConnectionManager.UdpConnection?.Dispose();
}
}
}
\ No newline at end of file
...@@ -56,6 +56,9 @@ ...@@ -56,6 +56,9 @@
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.39\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath> <HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.39\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
...@@ -124,6 +127,8 @@ ...@@ -124,6 +127,8 @@
<Compile Include="SettingView\View\SettingView.xaml.cs"> <Compile Include="SettingView\View\SettingView.xaml.cs">
<DependentUpon>SettingView.xaml</DependentUpon> <DependentUpon>SettingView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Setup\Provider\AppSetup_InitUDP.cs" />
<Compile Include="Setup\Provider\AppSetup_InitOpenCV.cs" />
<Compile Include="Setup\Provider\AppSetup_InitINI.cs" /> <Compile Include="Setup\Provider\AppSetup_InitINI.cs" />
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
......
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
<package id="Extended.Wpf.Toolkit" version="4.4.0" targetFramework="net48" /> <package id="Extended.Wpf.Toolkit" version="4.4.0" targetFramework="net48" />
<package id="log4net" version="2.0.14" targetFramework="net48" /> <package id="log4net" version="2.0.14" targetFramework="net48" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.39" targetFramework="net48" /> <package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.39" targetFramework="net48" />
<package id="SharpDX" version="4.2.0" targetFramework="net48" />
</packages> </packages>
\ No newline at end of file
...@@ -14,6 +14,24 @@ namespace VIZ.ElectricRabbit.Storage ...@@ -14,6 +14,24 @@ namespace VIZ.ElectricRabbit.Storage
public class ClientConfig : IniConfigBase public class ClientConfig : IniConfigBase
{ {
/// <summary> /// <summary>
/// OpenCV流索引
/// </summary>
[Ini(Section = "Client", DefaultValue = "1", Type = typeof(int))]
public string CLIENT_OPEN_CV_STREAM_INDEX { get; set; }
/// <summary>
/// 绑定IP
/// </summary>
[Ini(Section = "Client", DefaultValue = "127.0.0.1", Type = typeof(string))]
public string CLIENT_UDP_BINDING_IP { get; set; }
/// <summary>
/// 绑定端口
/// </summary>
[Ini(Section = "Client", DefaultValue = "8701", Type = typeof(int))]
public string CLIENT_UDP_BINDING_PORT { get; set; }
/// <summary>
/// 安全范围(单位:像素) /// 安全范围(单位:像素)
/// </summary> /// </summary>
[Ini(Section = "Client", DefaultValue = "200", Type = typeof(int))] [Ini(Section = "Client", DefaultValue = "200", Type = typeof(int))]
......
...@@ -19,6 +19,10 @@ namespace VIZ.ElectricRabbit ...@@ -19,6 +19,10 @@ namespace VIZ.ElectricRabbit
{ {
// 初始化 INI // 初始化 INI
AppSetup.AppendSetup(new AppSetup_InitINI()); AppSetup.AppendSetup(new AppSetup_InitINI());
// 初始化OpenCV
AppSetup.AppendSetup(new AppSetup_InitOpenCV());
// 初始化UDP
AppSetup.AppendSetup(new AppSetup_InitUDP());
// 执行启动流程 // 执行启动流程
AppSetupContext context = AppSetup.Setup(); AppSetupContext context = AppSetup.Setup();
......
...@@ -64,9 +64,29 @@ ...@@ -64,9 +64,29 @@
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.39\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath> <HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.39\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference> </Reference>
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<HintPath>..\packages\OpenCvSharp4.4.6.0.20220608\lib\net48\OpenCvSharp.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
......
...@@ -3,19 +3,23 @@ ...@@ -3,19 +3,23 @@
; ============================================================ ; ============================================================
[Application] [Application]
; 是否是调试模式 ; 是否是调试模式
APPLICATION_IS_DEBUG=false APPLICATION_IS_DEBUG=true
; ============================================================ ; ============================================================
; === Video === ; === Video ===
; ============================================================ ; ============================================================
[Video] [Video]
; 视频是否显示FPS
VIDEO_IS_SHOW_FPS=false
; 视频渲染等待(单位:毫秒) ; 视频渲染等待(单位:毫秒)
VIDEO_RENDER_WAIT=10 VIDEO_RENDER_WAIT=10
; ============================================================ ; ============================================================
; === Client === ; === Client ===
; ============================================================ ; ============================================================
[Client] [Client]
; OpenCV流索引
CLIENT_OPEN_CV_STREAM_INDEX=1
; 本机绑定IP
CLIENT_UDP_BINDING_IP=192.168.3.11
; 本机绑定端口
CLIENT_UDP_BINDING_PORT=8701
; 安全范围(单位:像素) ; 安全范围(单位:像素)
CLIENT_SAFE_DISTANCE=200 CLIENT_SAFE_DISTANCE=200
; 安全轴位置(单位:像素) ; 安全轴位置(单位:像素)
......
...@@ -3,4 +3,10 @@ ...@@ -3,4 +3,10 @@
<package id="Extended.Wpf.Toolkit" version="4.4.0" targetFramework="net48" /> <package id="Extended.Wpf.Toolkit" version="4.4.0" targetFramework="net48" />
<package id="log4net" version="2.0.14" targetFramework="net48" /> <package id="log4net" version="2.0.14" targetFramework="net48" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.39" targetFramework="net48" /> <package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.39" targetFramework="net48" />
<package id="OpenCvSharp4" version="4.6.0.20220608" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages> </packages>
\ No newline at end of file
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