Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王永辉
VIZ.Framework
Commits
4e8c9950
Commit
4e8c9950
authored
Aug 09, 2022
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加边线检测插件
parent
d0e6394a
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
534 additions
and
88 deletions
+534
-88
VIZ.Framework.Common.Resource/Style/Button/Button_WindowTop.xaml
+9
-64
VIZ.Framework.Common/VIZ.Framework.Common.csproj
+5
-0
VIZ.Framework.Common/VideoControl/Control/Plugin/SideCheckPolygon/EventArgs/SideCheckPolygonClickEventArgs.cs
+25
-0
VIZ.Framework.Common/VideoControl/Control/Plugin/SideCheckPolygon/Info/SideCheckPolygonInfo.cs
+30
-0
VIZ.Framework.Common/VideoControl/Control/Plugin/SideCheckPolygon/SideCheckPolygonExpand.cs
+47
-0
VIZ.Framework.Common/VideoControl/Control/Plugin/SideCheckPolygon/SideCheckPolygonPlugin.cs
+133
-0
VIZ.Framework.Common/VideoControl/Control/VideoControlPluginNames.cs
+5
-0
VIZ.Framework.Common/Widgets/LabelValue/LabelValue.xaml
+24
-0
VIZ.Framework.Common/Widgets/LabelValue/LabelValue2.cs
+104
-0
VIZ.Framework.Core/Core/Converter/Bool2SolidColorBrushConverter.cs
+59
-0
VIZ.Framework.Core/Core/Helper/ProcessHelper.cs
+30
-0
VIZ.Framework.Core/Core/Image/ImageHelper.cs
+3
-2
VIZ.Framework.Core/Core/Image/ImageHelperExpand.cs
+10
-0
VIZ.Framework.Core/VIZ.Framework.Core.csproj
+2
-0
VIZ.Framework.WpfTest/MainWindow.xaml
+1
-1
VIZ.Framework.WpfTest/VideoRender/OpenCVVideoTest.xaml.cs
+47
-21
No files found.
VIZ.Framework.Common.Resource/Style/Button/Button_WindowTop.xaml
View file @
4e8c9950
...
...
@@ -9,16 +9,13 @@
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="bd" BorderBrush="Transparent" BorderThickness="1" Background="Transparent">
<Grid x:Name="grid" HorizontalAlignment="Center" VerticalAlignment="Center" Width="20" Height="20" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<RotateTransform Angle="0"/>
</Grid.RenderTransform>
<Rectangle Width="20" Height="2" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<Grid x:Name="grid" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18" RenderTransformOrigin="0.5,0.5">
<Rectangle x:Name="rect1" Width="18" Height="2" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="45"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle
Width="20
" Height="2" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<Rectangle
x:Name="rect2" Width="18
" Height="2" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="-45"/>
</Rectangle.RenderTransform>
...
...
@@ -28,23 +25,9 @@
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="bd" Property="Background" Value="#22ffffff"></Setter>
<Setter TargetName="rect1" Property="Fill" Value="#ffff0000"></Setter>
<Setter TargetName="rect2" Property="Fill" Value="#ffff0000"></Setter>
</Trigger>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
Duration="00:00:00.3" To="180"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
Duration="00:00:00.3" To="0"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
...
...
@@ -59,33 +42,14 @@
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="bd" BorderBrush="Transparent" BorderThickness="1" Background="Transparent">
<Grid x:Name="grid" HorizontalAlignment="Center" VerticalAlignment="Center" Width="20" Height="20" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<RotateTransform Angle="0"/>
</Grid.RenderTransform>
<Rectangle Width="20" Height="2" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5"></Rectangle>
<Grid x:Name="grid" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18" RenderTransformOrigin="0.5,0.5">
<Rectangle Width="18" Height="2" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5"></Rectangle>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="bd" Property="Background" Value="#22ffffff"></Setter>
</Trigger>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
Duration="00:00:00.3" To="180"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
Duration="00:00:00.3" To="0"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
...
...
@@ -100,11 +64,8 @@
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="bd" BorderBrush="Transparent" BorderThickness="1" Background="Transparent">
<Grid x:Name="grid" HorizontalAlignment="Center" VerticalAlignment="Center" Width="20" Height="20" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<RotateTransform Angle="0"/>
</Grid.RenderTransform>
<Image Width="20" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center"
<Grid x:Name="grid" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18" RenderTransformOrigin="0.5,0.5">
<Image Width="18" Height="18" HorizontalAlignment="Center" VerticalAlignment="Center"
Source="/VIZ.Framework.Common.Resource;component/Icons/setting_32x32.png"></Image>
</Grid>
</Border>
...
...
@@ -112,22 +73,6 @@
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="bd" Property="Background" Value="#22ffffff"></Setter>
</Trigger>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
Duration="00:00:00.3" To="180"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
Duration="00:00:00.3" To="0"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
...
...
VIZ.Framework.Common/VIZ.Framework.Common.csproj
View file @
4e8c9950
...
...
@@ -194,6 +194,10 @@
<Compile Include="VideoControl\Control\Plugin\SelectionBox\Info\SelectionBoxInfo.cs" />
<Compile Include="VideoControl\Control\Plugin\SelectionBox\SelectionBoxExpand.cs" />
<Compile Include="VideoControl\Control\Plugin\SelectionBox\SelectionBoxPlugin.cs" />
<Compile Include="VideoControl\Control\Plugin\SideCheckPolygon\EventArgs\SideCheckPolygonClickEventArgs.cs" />
<Compile Include="VideoControl\Control\Plugin\SideCheckPolygon\Info\SideCheckPolygonInfo.cs" />
<Compile Include="VideoControl\Control\Plugin\SideCheckPolygon\SideCheckPolygonExpand.cs" />
<Compile Include="VideoControl\Control\Plugin\SideCheckPolygon\SideCheckPolygonPlugin.cs" />
<Compile Include="VideoControl\Control\Plugin\TrackingBox\EventArgs\TrackingBoxClickEventArgs.cs" />
<Compile Include="VideoControl\Control\Plugin\TrackingBox\TrackingBoxExpand.cs" />
<Compile Include="VideoControl\Control\Plugin\TrackingBox\Info\TrackingBoxInfo.cs" />
...
...
@@ -240,6 +244,7 @@
<Compile Include="Widgets\HotkeyBox\HotkeyBox.cs" />
<Compile Include="Widgets\HotkeyBox\HotkeyHelper.cs" />
<Compile Include="Widgets\HotkeyBox\HotkeyPropertyAttribute.cs" />
<Compile Include="Widgets\LabelValue\LabelValue2.cs" />
<Compile Include="Widgets\LabelValue\LabelValue.cs" />
<Compile Include="Widgets\NavigationControl\NavigationConfig.cs" />
<Compile Include="Widgets\NavigationControl\NavigationControl.cs" />
...
...
VIZ.Framework.Common/VideoControl/Control/Plugin/SideCheckPolygon/EventArgs/SideCheckPolygonClickEventArgs.cs
0 → 100644
View file @
4e8c9950
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 边线检测点击事件参数
/// </summary>
public
class
SideCheckPolygonClickEventArgs
:
EventArgs
{
/// <summary>
/// 鼠标点击位置
/// </summary>
public
Point
MousePoint
{
get
;
set
;
}
/// <summary>
/// 源坐标位置
/// </summary>
public
Point
SrcPoint
{
get
;
set
;
}
}
}
VIZ.Framework.Common/VideoControl/Control/Plugin/SideCheckPolygon/Info/SideCheckPolygonInfo.cs
0 → 100644
View file @
4e8c9950
using
SharpDX.Mathematics.Interop
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 边线检测多边形信息
/// </summary>
public
class
SideCheckPolygonInfo
{
/// <summary>
/// 编号
/// </summary>
public
string
ID
{
get
;
set
;
}
/// <summary>
/// 源点集合
/// </summary>
public
List
<
RawVector2
>
SrcPoints
{
get
;
set
;
}
/// <summary>
/// 填充颜色
/// </summary>
public
RawColor4
FillColor
{
get
;
set
;
}
}
}
VIZ.Framework.Common/VideoControl/Control/Plugin/SideCheckPolygon/SideCheckPolygonExpand.cs
0 → 100644
View file @
4e8c9950
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 边线检测多边形扩展
/// </summary>
public
static
class
SideCheckPolygonExpand
{
/// <summary>
/// 更新边线检测多边形
/// </summary>
/// <param name="videoControl">视频控件</param>
/// <param name="sideCheckPolygonInfos">边线检测多边形信息</param>
public
static
void
UpdateSideCheckPolygon
(
this
VideoControl
videoControl
,
List
<
SideCheckPolygonInfo
>
sideCheckPolygonInfos
)
{
if
(
videoControl
.
videoRender
==
null
)
return
;
SideCheckPolygonPlugin
plugin
=
videoControl
.
GetPlugin
<
SideCheckPolygonPlugin
>(
VideoControlPluginNames
.
SideCheckPolygon
);
if
(
plugin
==
null
)
return
;
plugin
.
Update
(
sideCheckPolygonInfos
);
}
/// <summary>
/// 清理边线检测多边形
/// </summary>
/// <param name="videoControl">视频控件</param>
public
static
void
ClearSideCheckPolygon
(
this
VideoControl
videoControl
)
{
if
(
videoControl
.
videoRender
==
null
)
return
;
SideCheckPolygonPlugin
plugin
=
videoControl
.
GetPlugin
<
SideCheckPolygonPlugin
>(
VideoControlPluginNames
.
SideCheckPolygon
);
if
(
plugin
==
null
)
return
;
plugin
.
Update
(
null
);
}
}
}
VIZ.Framework.Common/VideoControl/Control/Plugin/SideCheckPolygon/SideCheckPolygonPlugin.cs
0 → 100644
View file @
4e8c9950
using
SharpDX.Direct2D1
;
using
SharpDX.Mathematics.Interop
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 边线检测多边形插件
/// </summary>
public
class
SideCheckPolygonPlugin
:
VideoPluginBase
{
/// <summary>
/// 框选框插件
/// </summary>
/// <param name="videoControl">视频控件</param>
public
SideCheckPolygonPlugin
(
VideoControl
videoControl
)
:
base
(
videoControl
)
{
}
/// <summary>
/// 名称
/// </summary>
public
override
string
Name
=>
VideoControlPluginNames
.
SideCheckPolygon
;
/// <summary>
/// 鼠标点击时触发
/// </summary>
public
event
EventHandler
<
SideCheckPolygonClickEventArgs
>
Click
;
/// <summary>
/// 边线检测框信息
/// </summary>
private
volatile
List
<
SideCheckPolygonInfo
>
sideCheckPolygonInfos
;
/// <summary>
/// 更新数据
/// </summary>
/// <param name="sideCheckPolygonInfos">边线检测框信息</param>
public
void
Update
(
List
<
SideCheckPolygonInfo
>
sideCheckPolygonInfos
)
{
this
.
sideCheckPolygonInfos
=
sideCheckPolygonInfos
;
}
/// <summary>
/// 渲染
/// </summary>
/// <param name="context">渲染上下文</param>
public
override
void
Render
(
VideoRenderContext
context
)
{
List
<
SideCheckPolygonInfo
>
sideCheckPolygonInfos
=
this
.
sideCheckPolygonInfos
;
if
(
sideCheckPolygonInfos
==
null
||
sideCheckPolygonInfos
.
Count
==
0
)
return
;
foreach
(
SideCheckPolygonInfo
info
in
sideCheckPolygonInfos
)
{
if
(
info
.
SrcPoints
==
null
||
info
.
SrcPoints
.
Count
<=
1
)
continue
;
SolidColorBrush
brush
=
new
SolidColorBrush
(
context
.
Target
,
info
.
FillColor
);
PathGeometry
geometry
=
new
PathGeometry
(
context
.
Target
.
Factory
);
GeometrySink
sink
=
geometry
.
Open
();
if
(
context
.
Mode
==
VideoRenderMode
.
UI
)
{
RawVector2
first_point
=
ImageHelper
.
ConvertImagePointToUiPoint
(
context
.
VideoRenderInfo
.
Frame
.
Width
,
context
.
VideoRenderInfo
.
Frame
.
Height
,
context
.
VideoRenderInfo
.
DrawingRect
,
info
.
SrcPoints
[
0
]);
sink
.
BeginFigure
(
first_point
,
FigureBegin
.
Filled
);
for
(
int
i
=
1
;
i
<
info
.
SrcPoints
.
Count
;
++
i
)
{
RawVector2
point
=
ImageHelper
.
ConvertImagePointToUiPoint
(
context
.
VideoRenderInfo
.
Frame
.
Width
,
context
.
VideoRenderInfo
.
Frame
.
Height
,
context
.
VideoRenderInfo
.
DrawingRect
,
info
.
SrcPoints
[
i
]);
sink
.
AddLine
(
point
);
}
sink
.
EndFigure
(
FigureEnd
.
Closed
);
}
else
{
sink
.
BeginFigure
(
info
.
SrcPoints
[
0
],
FigureBegin
.
Filled
);
for
(
int
i
=
1
;
i
<
info
.
SrcPoints
.
Count
-
1
;
++
i
)
{
sink
.
AddLine
(
info
.
SrcPoints
[
i
]);
}
sink
.
EndFigure
(
FigureEnd
.
Closed
);
}
sink
.
Close
();
context
.
Target
.
FillGeometry
(
geometry
,
brush
);
}
}
/// <summary>
/// 附加
/// </summary>
public
override
void
Attach
()
{
this
.
VideoRender
.
PreviewMouseLeftButtonDown
-=
VideoRender_PreviewMouseLeftButtonDown
;
this
.
VideoRender
.
PreviewMouseLeftButtonDown
+=
VideoRender_PreviewMouseLeftButtonDown
;
}
/// <summary>
/// 卸载
/// </summary>
public
override
void
Detach
()
{
this
.
VideoRender
.
PreviewMouseLeftButtonDown
-=
VideoRender_PreviewMouseLeftButtonDown
;
}
/// <summary>
/// 鼠标左键点击
/// </summary>
private
void
VideoRender_PreviewMouseLeftButtonDown
(
object
sender
,
System
.
Windows
.
Input
.
MouseButtonEventArgs
e
)
{
if
(!
this
.
IsEnabled
||
this
.
Click
==
null
)
return
;
VideoRenderInfo
renderInfo
=
this
.
VideoRender
.
RenderInfo
;
if
(
renderInfo
==
null
)
return
;
SideCheckPolygonClickEventArgs
args
=
new
SideCheckPolygonClickEventArgs
();
args
.
MousePoint
=
e
.
GetPosition
(
this
.
VideoRender
);
args
.
SrcPoint
=
ImageHelper
.
ConvertUiPointToImagePoint
(
renderInfo
.
Frame
.
Width
,
renderInfo
.
Frame
.
Height
,
renderInfo
.
DrawingRect
,
args
.
MousePoint
);
this
.
Click
.
Invoke
(
this
,
args
);
}
}
}
\ No newline at end of file
VIZ.Framework.Common/VideoControl/Control/VideoControlPluginNames.cs
View file @
4e8c9950
...
...
@@ -25,5 +25,10 @@ namespace VIZ.Framework.Common
/// 裁剪框
/// </summary>
public
const
string
ClipBox
=
"ClipBox"
;
/// <summary>
/// 边线检测多边形
/// </summary>
public
const
string
SideCheckPolygon
=
"SideCheckPolygon"
;
}
}
VIZ.Framework.Common/Widgets/LabelValue/LabelValue.xaml
View file @
4e8c9950
...
...
@@ -25,4 +25,27 @@
</Setter>
</Style>
<Style TargetType="local:LabelValue2">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:LabelValue2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Foreground="#aa000000"
Text="{TemplateBinding Label}" Width="{TemplateBinding LabelWidth}"></TextBlock>
<TextBox Grid.Column="1" AcceptsReturn="False" IsReadOnly="True" TextWrapping="NoWrap"
Text="{TemplateBinding Text1}" VerticalContentAlignment="Center" Style="{StaticResource TextBox_None}"></TextBox>
<TextBox Grid.Column="2" AcceptsReturn="False" IsReadOnly="True" TextWrapping="NoWrap"
Text="{TemplateBinding Text2}" VerticalContentAlignment="Center" Style="{StaticResource TextBox_None}"></TextBox>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
VIZ.Framework.Common/Widgets/LabelValue/LabelValue2.cs
0 → 100644
View file @
4e8c9950
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 标签和值
/// </summary>
public
class
LabelValue2
:
Control
{
static
LabelValue2
()
{
DefaultStyleKeyProperty
.
OverrideMetadata
(
typeof
(
LabelValue2
),
new
FrameworkPropertyMetadata
(
typeof
(
LabelValue2
)));
}
#
region
LabelWidth
--
标签宽度
/// <summary>
/// 标签宽度
/// </summary>
public
double
LabelWidth
{
get
{
return
(
double
)
GetValue
(
LabelWidthProperty
);
}
set
{
SetValue
(
LabelWidthProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for LabelWidth. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
LabelWidthProperty
=
DependencyProperty
.
Register
(
"LabelWidth"
,
typeof
(
double
),
typeof
(
LabelValue2
),
new
PropertyMetadata
(
120d
));
#
endregion
#
region
Label
--
标签
/// <summary>
/// 标签
/// </summary>
public
string
Label
{
get
{
return
(
string
)
GetValue
(
LabelProperty
);
}
set
{
SetValue
(
LabelProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for Label. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
LabelProperty
=
DependencyProperty
.
Register
(
"Label"
,
typeof
(
string
),
typeof
(
LabelValue2
),
new
PropertyMetadata
(
null
));
#
endregion
#
region
Text1
--
文本
1
/// <summary>
/// 文本1
/// </summary>
public
string
Text1
{
get
{
return
(
string
)
GetValue
(
Text1Property
);
}
set
{
SetValue
(
Text1Property
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for Text1. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
Text1Property
=
DependencyProperty
.
Register
(
"Text1"
,
typeof
(
string
),
typeof
(
LabelValue2
),
new
PropertyMetadata
(
null
));
#
endregion
#
region
Text2
--
文本
2
/// <summary>
/// 文本2
/// </summary>
public
string
Text2
{
get
{
return
(
string
)
GetValue
(
Text2Property
);
}
set
{
SetValue
(
Text2Property
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for Text2. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
Text2Property
=
DependencyProperty
.
Register
(
"Text2"
,
typeof
(
string
),
typeof
(
LabelValue2
),
new
PropertyMetadata
(
null
));
#
endregion
}
}
VIZ.Framework.Core/Core/Converter/Bool2SolidColorBrushConverter.cs
0 → 100644
View file @
4e8c9950
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Data
;
using
System.Windows.Media
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// Bool -> SolidColorBrush 转化器
/// </summary>
public
class
Bool2SolidColorBrushConverter
:
IValueConverter
{
/// <summary>
/// 值为None时的画刷
/// </summary>
public
Brush
NoneBrush
{
get
;
set
;
}
=
new
SolidColorBrush
(
Colors
.
White
);
/// <summary>
/// 值为False时的画刷
/// </summary>
public
Brush
FalseBrush
{
get
;
set
;
}
=
new
SolidColorBrush
(
Colors
.
White
);
/// <summary>
/// 值为True时的画刷
/// </summary>
public
Brush
TrueBrush
{
get
;
set
;
}
=
new
SolidColorBrush
(
Colors
.
Red
);
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(
value
is
bool
?)
{
bool
?
b
=
(
bool
?)
value
;
if
(
b
==
null
)
return
this
.
NoneBrush
;
return
b
.
Value
?
this
.
TrueBrush
:
this
.
FalseBrush
;
}
else
if
(
value
is
bool
)
{
bool
b
=
(
bool
)
value
;
return
b
?
this
.
TrueBrush
:
this
.
FalseBrush
;
}
else
{
return
this
.
NoneBrush
;
}
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
}
VIZ.Framework.Core/Core/Helper/ProcessHelper.cs
0 → 100644
View file @
4e8c9950
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Management
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// 进程辅助类
/// </summary>
public
static
class
ProcessHelper
{
/// <summary>
/// 获取进程的启动命令行
/// </summary>
/// <param name="process">进程对象</param>
/// <returns>启动命令行</returns>
public
static
string
GetCommandLine
(
Process
process
)
{
using
(
ManagementObjectSearcher
searcher
=
new
ManagementObjectSearcher
(
"SELECT CommandLine FROM Win32_Process WHERE ProcessId = "
+
process
.
Id
))
using
(
ManagementObjectCollection
objects
=
searcher
.
Get
())
{
return
objects
.
Cast
<
ManagementBaseObject
>().
SingleOrDefault
()?[
"CommandLine"
]?.
ToString
()
??
string
.
Empty
;
}
}
}
}
VIZ.Framework.Core/Core/Image/ImageHelper.cs
View file @
4e8c9950
...
...
@@ -4,6 +4,7 @@ using System.Windows;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
SharpDX.Mathematics.Interop
;
namespace
VIZ.Framework.Core
{
...
...
@@ -153,7 +154,7 @@ namespace VIZ.Framework.Core
/// <param name="uiDrawRect">图片在UI的绘制区域</param>
/// <param name="imgPoint">图片坐标点</param>
/// <returns>UI坐标点</returns>
public
static
Point
ConvertImagePointToUiPoint
(
int
imgWidth
,
int
imgHeight
,
Rect
uiDrawRect
,
Rect
imgPoint
)
public
static
RawVector2
ConvertImagePointToUiPoint
(
int
imgWidth
,
int
imgHeight
,
Rect
uiDrawRect
,
RawVector2
imgPoint
)
{
double
xp
=
uiDrawRect
.
Width
/
imgWidth
;
double
yp
=
uiDrawRect
.
Height
/
imgHeight
;
...
...
@@ -161,7 +162,7 @@ namespace VIZ.Framework.Core
double
destX
=
uiDrawRect
.
X
+
imgPoint
.
X
*
xp
;
double
destY
=
uiDrawRect
.
Y
+
imgPoint
.
Y
*
yp
;
return
new
Point
(
destX
,
destY
);
return
new
RawVector2
((
float
)
destX
,
(
float
)
destY
);
}
/// <summary>
...
...
VIZ.Framework.Core/Core/Image/ImageHelperExpand.cs
View file @
4e8c9950
...
...
@@ -34,5 +34,15 @@ namespace VIZ.Framework.Core
{
return
new
RawRectangleF
((
float
)
rect
.
Left
,
(
float
)
rect
.
Top
,
(
float
)
rect
.
Right
,
(
float
)
rect
.
Bottom
);
}
/// <summary>
/// 将Point转化为RawVector2
/// </summary>
/// <param name="point">点</param>
/// <returns>RawVector2</returns>
public
static
RawVector2
ToRawVector2
(
this
System
.
Windows
.
Point
point
)
{
return
new
RawVector2
((
float
)
point
.
X
,
(
float
)
point
.
Y
);
}
}
}
VIZ.Framework.Core/VIZ.Framework.Core.csproj
View file @
4e8c9950
...
...
@@ -89,7 +89,9 @@
<ItemGroup>
<Compile Include="Core\Converter\Bool2BoolConverter.cs" />
<Compile Include="Core\Converter\ByteSizeConverter.cs" />
<Compile Include="Core\Converter\Bool2SolidColorBrushConverter.cs" />
<Compile Include="Core\Enum\EnumHelper.cs" />
<Compile Include="Core\Helper\ProcessHelper.cs" />
<Compile Include="Expand\GPI\GPIManager.cs" />
<Compile Include="Expand\GPI\GPI_USB2GPI_DEVICE.cs" />
<Compile Include="Expand\GPI\GPI_USB_DEVICE.cs" />
...
...
VIZ.Framework.WpfTest/MainWindow.xaml
View file @
4e8c9950
...
...
@@ -8,6 +8,6 @@
mc:Ignorable="d" WindowStartupLocation="CenterScreen" WindowState="Maximized" WindowStyle="None"
Title="MainWindow" Height="800" Width="1200">
<Grid>
<local:
HotkeyBoxTest></local:HotkeyBox
Test>
<local:
OpenCVVideoTest></local:OpenCVVideo
Test>
</Grid>
</Window>
VIZ.Framework.WpfTest/VideoRender/OpenCVVideoTest.xaml.cs
View file @
4e8c9950
...
...
@@ -39,9 +39,13 @@ namespace VIZ.Framework.WpfTest
ClipBoxPlugin
clipBoxPlugin
=
new
ClipBoxPlugin
(
this
.
video
);
SideCheckPolygonPlugin
sideCheckPolygonPlugin
=
new
SideCheckPolygonPlugin
(
this
.
video
);
sideCheckPolygonPlugin
.
Click
+=
SideCheckPolygonPlugin_Click
;
this
.
video
.
AttachPlugin
(
trackingBoxPlugin
);
this
.
video
.
AttachPlugin
(
selectionBoxPlugin
);
this
.
video
.
AttachPlugin
(
clipBoxPlugin
);
this
.
video
.
AttachPlugin
(
sideCheckPolygonPlugin
);
// 接入OpenCV插件
OpenCVStreamOption
option
=
new
OpenCVStreamOption
();
...
...
@@ -51,31 +55,53 @@ namespace VIZ.Framework.WpfTest
stream
.
Play
();
// 更新矩形框信息
List
<
TrackingBoxInfo
>
list
=
new
List
<
TrackingBoxInfo
>();
list
.
Add
(
new
TrackingBoxInfo
{
DrawingBorderColor
=
SharpDxColorHelper
.
FromString
(
"#FFFF0000"
),
ID
=
"1"
,
DrawingBorderWidth
=
4
,
SrcRect
=
new
SharpDX
.
Mathematics
.
Interop
.
RawRectangleF
(
0
,
0
,
200
,
120
)
});
list
.
Add
(
new
TrackingBoxInfo
//List<TrackingBoxInfo> list = new List<TrackingBoxInfo>();
//list.Add(new TrackingBoxInfo
//{
// DrawingBorderColor = SharpDxColorHelper.FromString("#FFFF0000"),
// ID = "1",
// DrawingBorderWidth = 4,
// SrcRect = new SharpDX.Mathematics.Interop.RawRectangleF(0, 0, 200, 120)
//});
//list.Add(new TrackingBoxInfo
//{
// DrawingBorderColor = SharpDxColorHelper.FromString("#FFFF0000"),
// ID = "1",
// DrawingBorderWidth = 4,
// SrcRect = new SharpDX.Mathematics.Interop.RawRectangleF(400, 300, 600, 420)
//});
//this.video.UpdateTrackingBox(list);
// 裁剪
//ClipBoxInfo clipBoxInfo = new ClipBoxInfo();
//clipBoxInfo.DrawingBorderWidth = 8;
//clipBoxInfo.DrawingBorderColor = SharpDxColorHelper.FromString("#AA0000FF");
//clipBoxInfo.MaskColor = SharpDxColorHelper.FromString("#66000000");
//clipBoxInfo.SrcRect = new SharpDX.Mathematics.Interop.RawRectangleF(200, 0, 800, 1080);
//this.video.UpdateClipBox(clipBoxInfo);
// 边线检测
List
<
SideCheckPolygonInfo
>
sideCheckPolygonInfos
=
new
List
<
SideCheckPolygonInfo
>();
sideCheckPolygonInfos
.
Add
(
new
SideCheckPolygonInfo
{
DrawingBorderColor
=
SharpDxColorHelper
.
FromString
(
"#FFFF0000"
),
ID
=
"1"
,
DrawingBorderWidth
=
4
,
SrcRect
=
new
SharpDX
.
Mathematics
.
Interop
.
RawRectangleF
(
400
,
300
,
600
,
420
)
FillColor
=
SharpDxColorHelper
.
FromString
(
"#66FF000000"
),
SrcPoints
=
new
List
<
SharpDX
.
Mathematics
.
Interop
.
RawVector2
>()
{
new
SharpDX
.
Mathematics
.
Interop
.
RawVector2
(
100
,
100
),
new
SharpDX
.
Mathematics
.
Interop
.
RawVector2
(
300
,
100
),
new
SharpDX
.
Mathematics
.
Interop
.
RawVector2
(
500
,
300
),
new
SharpDX
.
Mathematics
.
Interop
.
RawVector2
(
600
,
500
),
new
SharpDX
.
Mathematics
.
Interop
.
RawVector2
(
100
,
100
)
}
});
this
.
video
.
UpdateTrackingBox
(
list
);
// 裁剪
ClipBoxInfo
clipBoxInfo
=
new
ClipBoxInfo
();
clipBoxInfo
.
DrawingBorderWidth
=
8
;
clipBoxInfo
.
DrawingBorderColor
=
SharpDxColorHelper
.
FromString
(
"#AA0000FF"
);
clipBoxInfo
.
MaskColor
=
SharpDxColorHelper
.
FromString
(
"#66000000"
);
clipBoxInfo
.
SrcRect
=
new
SharpDX
.
Mathematics
.
Interop
.
RawRectangleF
(
200
,
0
,
800
,
1080
);
this
.
video
.
UpdateSideCheckPolygon
(
sideCheckPolygonInfos
);
}
this
.
video
.
UpdateClipBox
(
clipBoxInfo
);
private
void
SideCheckPolygonPlugin_Click
(
object
sender
,
SideCheckPolygonClickEventArgs
e
)
{
Debug
.
WriteLine
(
$"SideCheckPolygonPlugin_Click: [
{
e
.
MousePoint
.
X
}
,
{
e
.
MousePoint
.
Y
}
] [
{
e
.
SrcPoint
.
X
}
,
{
e
.
SrcPoint
.
Y
}
]"
);
}
private
void
Stream_ExecuteVideoFrame
(
object
sender
,
VideoFrameEventArgs
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment