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
8a28afd4
Commit
8a28afd4
authored
Mar 31, 2023
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加滤波算法
parent
f6ec046c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
211 additions
and
3 deletions
+211
-3
VIZ.Framework.Common/VideoControl/Control/VideoRenderRotationEnum.cs
+29
-0
VIZ.Framework.Common/VideoControl/Stream/NDI/Task/NDIStreamRecvVideoTask.cs
+31
-2
VIZ.Framework.Common/VideoControl/Stream/VideoStreamOptionBase.cs
+7
-1
VIZ.Framework.Core/Expand/ThreeDMouse/Navigation3DSmoothWithSavitzkyGolay.cs
+134
-0
VIZ.Framework.Core/VIZ.Framework.Core.csproj
+9
-0
VIZ.Framework.Core/packages.config
+1
-0
No files found.
VIZ.Framework.Common/VideoControl/Control/VideoRenderRotationEnum.cs
0 → 100644
View file @
8a28afd4
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 视频旋转模式
/// </summary>
public
enum
VideoRenderRotationEnum
{
/// <summary>
/// 不旋转
/// </summary>
None
,
/// <summary>
/// 顺时针
/// </summary>
Clockwise
,
/// <summary>
/// 逆时针
/// </summary>
Anticlockwise
}
}
VIZ.Framework.Common/VideoControl/Stream/NDI/Task/NDIStreamRecvVideoTask.cs
View file @
8a28afd4
...
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
...
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using
System.Threading
;
using
System.Threading
;
using
System.Drawing
;
using
System.Drawing
;
using
System.Drawing.Imaging
;
using
System.Drawing.Imaging
;
using
OpenCvSharp
;
namespace
VIZ.Framework.Common
namespace
VIZ.Framework.Common
{
{
...
@@ -94,15 +95,43 @@ namespace VIZ.Framework.Common
...
@@ -94,15 +95,43 @@ namespace VIZ.Framework.Common
}
}
NDIStreamVideoFrame
videoFrame
=
new
NDIStreamVideoFrame
();
NDIStreamVideoFrame
videoFrame
=
new
NDIStreamVideoFrame
();
videoFrame
.
Width
=
frame
.
xres
;
videoFrame
.
Height
=
frame
.
yres
;
videoFrame
.
Length
=
frame
.
xres
*
frame
.
yres
*
4
;
videoFrame
.
Length
=
frame
.
xres
*
frame
.
yres
*
4
;
videoFrame
.
TimeStamp
=
frame
.
timestamp
;
videoFrame
.
TimeStamp
=
frame
.
timestamp
;
videoFrame
.
DataStream
=
new
SharpDX
.
DataStream
(
videoFrame
.
Length
,
true
,
true
);
videoFrame
.
DataStream
=
new
SharpDX
.
DataStream
(
videoFrame
.
Length
,
true
,
true
);
unsafe
unsafe
{
{
if
(
this
.
Stream
.
Option
.
Rotation
.
HasValue
)
{
if
(
this
.
Stream
.
Option
.
Rotation
==
RotateFlags
.
Rotate180
)
{
videoFrame
.
Width
=
frame
.
xres
;
videoFrame
.
Height
=
frame
.
yres
;
}
else
{
videoFrame
.
Width
=
frame
.
yres
;
videoFrame
.
Height
=
frame
.
xres
;
}
Mat
srcMat
=
new
Mat
(
new
OpenCvSharp
.
Size
(
frame
.
xres
,
frame
.
yres
),
MatType
.
CV_8UC4
);
Buffer
.
MemoryCopy
(
frame
.
p_data
.
ToPointer
(),
srcMat
.
DataPointer
,
videoFrame
.
Length
,
videoFrame
.
Length
);
Mat
dstMat
=
new
Mat
();
Cv2
.
Rotate
(
srcMat
,
dstMat
,
this
.
Stream
.
Option
.
Rotation
.
Value
);
Buffer
.
MemoryCopy
(
dstMat
.
DataPointer
,
videoFrame
.
DataStream
.
DataPointer
.
ToPointer
(),
videoFrame
.
Length
,
videoFrame
.
Length
);
dstMat
.
Dispose
();
srcMat
.
Dispose
();
}
else
{
videoFrame
.
Width
=
frame
.
xres
;
videoFrame
.
Height
=
frame
.
yres
;
Buffer
.
MemoryCopy
(
frame
.
p_data
.
ToPointer
(),
videoFrame
.
DataStream
.
DataPointer
.
ToPointer
(),
videoFrame
.
Length
,
videoFrame
.
Length
);
Buffer
.
MemoryCopy
(
frame
.
p_data
.
ToPointer
(),
videoFrame
.
DataStream
.
DataPointer
.
ToPointer
(),
videoFrame
.
Length
,
videoFrame
.
Length
);
}
}
}
this
.
Stream
.
VideoFrameQueue
.
Enqueue
(
videoFrame
);
this
.
Stream
.
VideoFrameQueue
.
Enqueue
(
videoFrame
);
...
...
VIZ.Framework.Common/VideoControl/Stream/VideoStreamOptionBase.cs
View file @
8a28afd4
using
System
;
using
OpenCvSharp
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
...
@@ -15,5 +16,10 @@ namespace VIZ.Framework.Common
...
@@ -15,5 +16,10 @@ namespace VIZ.Framework.Common
/// 延时帧
/// 延时帧
/// </summary>
/// </summary>
public
int
DelayFrame
{
get
;
set
;
}
public
int
DelayFrame
{
get
;
set
;
}
/// <summary>
/// 旋转
/// </summary>
public
RotateFlags
?
Rotation
{
get
;
set
;
}
}
}
}
}
VIZ.Framework.Core/Expand/ThreeDMouse/Navigation3DSmoothWithSavitzkyGolay.cs
0 → 100644
View file @
8a28afd4
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Runtime.CompilerServices
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Altaxo.Calc.Regression
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// Savitzky Golay 算法平滑 返回值
/// </summary>
public
class
Navigation3DSmoothWithSavitzkyGolayResult
{
/// <summary>
/// Savitzky Golay 算法平滑 返回值
/// </summary>
/// <param name="timeCode">时码</param>
/// <param name="value">值</param>
public
Navigation3DSmoothWithSavitzkyGolayResult
(
long
timeCode
,
double
value
)
{
this
.
TimeCode
=
timeCode
;
this
.
Value
=
value
;
}
/// <summary>
/// 时码
/// </summary>
public
long
TimeCode
{
get
;
private
set
;
}
/// <summary>
/// 值
/// </summary>
public
double
Value
{
get
;
private
set
;
}
}
/// <summary>
/// Savitzky Golay 算法平滑
/// </summary>
public
class
Navigation3DSmoothWithSavitzkyGolay
{
/// <summary>
/// 锁对象
/// </summary>
private
object
lock_object
=
new
object
();
/// <summary>
/// 时码队列
/// </summary>
public
Queue
<
long
>
TimeCodeQueue
{
get
;
}
=
new
Queue
<
long
>();
/// <summary>
/// 值队列
/// </summary>
public
Queue
<
double
>
ValueQueue
{
get
;
}
=
new
Queue
<
double
>();
/// <summary>
/// 队列长度
/// </summary>
public
int
QueueLength
{
get
;
private
set
;
}
/// <summary>
/// 过滤器
/// </summary>
private
SavitzkyGolay
Filter
;
/// <summary>
/// Savitzky Golay 算法平滑
/// </summary>
/// <param name="windowWidth">窗口宽度</param>
/// <param name="polynomialDegree">幂</param>
/// <param name="queueLength">队列长度</param>
public
Navigation3DSmoothWithSavitzkyGolay
(
int
windowWidth
,
int
polynomialDegree
,
int
queueLength
)
{
this
.
Filter
=
new
SavitzkyGolay
(
windowWidth
,
0
,
polynomialDegree
);
this
.
QueueLength
=
queueLength
;
}
/// <summary>
/// 平滑
/// </summary>
/// <param name="timeCode">时码</param>
/// <param name="value">输入值</param>
/// <returns>平滑后的值</returns>
public
Navigation3DSmoothWithSavitzkyGolayResult
Smooth
(
long
timeCode
,
double
value
)
{
lock
(
this
.
lock_object
)
{
this
.
TimeCodeQueue
.
Enqueue
(
timeCode
);
this
.
ValueQueue
.
Enqueue
(
value
);
if
(
this
.
TimeCodeQueue
.
Count
<
this
.
QueueLength
)
{
return
new
Navigation3DSmoothWithSavitzkyGolayResult
(
timeCode
,
value
);
}
if
(
this
.
TimeCodeQueue
.
Count
>
this
.
QueueLength
)
{
this
.
TimeCodeQueue
.
Dequeue
();
this
.
ValueQueue
.
Dequeue
();
}
}
double
[]
dst
=
new
double
[
this
.
ValueQueue
.
Count
];
this
.
Filter
.
Apply
(
this
.
ValueQueue
.
ToArray
(),
dst
);
double
dst_value
=
dst
[
this
.
QueueLength
/
2
];
long
dst_timeCode
=
this
.
TimeCodeQueue
.
ToArray
()[
this
.
QueueLength
/
2
];
return
new
Navigation3DSmoothWithSavitzkyGolayResult
(
dst_timeCode
,
dst_value
);
}
/// <summary>
/// 更新参数
/// </summary>
/// <param name="windowWidth">窗口宽度</param>
/// <param name="polynomialDegree">幂</param>
/// <param name="queueLength">队列长度</param>
public
void
UpdateOption
(
int
windowWidth
,
int
polynomialDegree
,
int
queueLength
)
{
lock
(
this
.
lock_object
)
{
this
.
Filter
=
new
SavitzkyGolay
(
windowWidth
,
0
,
polynomialDegree
);
this
.
QueueLength
=
queueLength
;
this
.
TimeCodeQueue
.
Clear
();
this
.
ValueQueue
.
Clear
();
}
}
}
}
VIZ.Framework.Core/VIZ.Framework.Core.csproj
View file @
8a28afd4
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
...
@@ -49,9 +51,15 @@
...
@@ -49,9 +51,15 @@
<ErrorReport>prompt</ErrorReport>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference Include="AltaxoCore">
<HintPath>..\05-Lib\AltaxoCore.dll</HintPath>
</Reference>
<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="Microsoft.Solver.Foundation, Version=3.0.2.10889, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\VIZ.H2V\packages\Microsoft.Solver.Foundation.3.1.0\lib\Microsoft.Solver.Foundation.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<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>
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
...
@@ -190,6 +198,7 @@
...
@@ -190,6 +198,7 @@
<Compile Include="Expand\ThreeDMouse\Core\Navigation3DHelper.cs" />
<Compile Include="Expand\ThreeDMouse\Core\Navigation3DHelper.cs" />
<Compile Include="Expand\ThreeDMouse\Navigation3DDataInfo.cs" />
<Compile Include="Expand\ThreeDMouse\Navigation3DDataInfo.cs" />
<Compile Include="Expand\ThreeDMouse\Navigation3DMapping.cs" />
<Compile Include="Expand\ThreeDMouse\Navigation3DMapping.cs" />
<Compile Include="Expand\ThreeDMouse\Navigation3DSmoothWithSavitzkyGolay.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Expand\SharpDx\RawRectangleFExpand.cs" />
<Compile Include="Expand\SharpDx\RawRectangleFExpand.cs" />
<Compile Include="Expand\SharpDx\SharpDxColorHelper.cs" />
<Compile Include="Expand\SharpDx\SharpDxColorHelper.cs" />
...
...
VIZ.Framework.Core/packages.config
View file @
8a28afd4
<?
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
=
"Microsoft.Solver.Foundation"
version
=
"3.1.0"
targetFramework
=
"net48"
/>
<
package
id
=
"Newtonsoft.Json"
version
=
"13.0.1"
targetFramework
=
"net48"
/>
<
package
id
=
"Newtonsoft.Json"
version
=
"13.0.1"
targetFramework
=
"net48"
/>
<
package
id
=
"NvAPIWrapper.Net"
version
=
"0.8.1.101"
targetFramework
=
"net48"
/>
<
package
id
=
"NvAPIWrapper.Net"
version
=
"0.8.1.101"
targetFramework
=
"net48"
/>
<
package
id
=
"SharpDX"
version
=
"4.2.0"
targetFramework
=
"net48"
/>
<
package
id
=
"SharpDX"
version
=
"4.2.0"
targetFramework
=
"net48"
/>
...
...
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