Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.H2V
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.H2V
Commits
c4be4b7c
Commit
c4be4b7c
authored
Sep 02, 2022
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
裁切录制
parent
8a094dd9
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
94 additions
and
50 deletions
+94
-50
VIZ.H2V.ClipTestTool/ViewModel/MainViewModel.cs
+0
-1
VIZ.H2V.Module/NDIView/Controller/Algorithm/IAlgorithmSupport.cs
+1
-1
VIZ.H2V.Module/NDIView/Controller/Manual/ManualController.cs
+9
-1
VIZ.H2V.Module/NDIView/Controller/Recording/NDIViewRecording.cs
+63
-10
VIZ.H2V.Module/NDIView/Controller/Recording/RecordingController.cs
+5
-4
VIZ.H2V.Module/NDIView/VieweModel/NDIViewModel.Command.cs
+4
-4
VIZ.H2V.Module/NDIView/VieweModel/NDIViewModel.Manual_NDI.cs
+8
-25
VIZ.H2V.Module/NDIView/VieweModel/NDIViewModel.Property.cs
+2
-2
VIZ.H2V.Module/NDIView/VieweModel/NDIViewModel.cs
+1
-1
VIZ.H2V/App.xaml.cs
+1
-1
No files found.
VIZ.H2V.ClipTestTool/ViewModel/MainViewModel.cs
View file @
c4be4b7c
...
@@ -284,7 +284,6 @@ namespace VIZ.H2V.ClipTestTool
...
@@ -284,7 +284,6 @@ namespace VIZ.H2V.ClipTestTool
if
(
manager
==
null
)
if
(
manager
==
null
)
return
;
return
;
log
.
Debug
(
$"发送:
{
this
.
ClipX
}
, ||
{
e
.
Frame
.
TimeStamp
}
"
);
ClipSender
.
CropRoi
(
manager
,
0
,
new
List
<
int
>
{
this
.
ClipX
,
0
,
this
.
ClipX
+
810
,
e
.
Frame
.
Height
},
810
,
e
.
Frame
.
Height
,
e
.
Frame
.
TimeStamp
);
ClipSender
.
CropRoi
(
manager
,
0
,
new
List
<
int
>
{
this
.
ClipX
,
0
,
this
.
ClipX
+
810
,
e
.
Frame
.
Height
},
810
,
e
.
Frame
.
Height
,
e
.
Frame
.
TimeStamp
);
}
}
}
}
...
...
VIZ.H2V.Module/NDIView/Controller/Algorithm/IAlgorithmSupport.cs
View file @
c4be4b7c
...
@@ -52,7 +52,7 @@ namespace VIZ.H2V.Module
...
@@ -52,7 +52,7 @@ namespace VIZ.H2V.Module
/// <summary>
/// <summary>
/// 裁切框X坐标
/// 裁切框X坐标
/// </summary>
/// </summary>
double
?
ClipBoxX
{
get
;
}
double
ClipBoxX
{
get
;
}
/// <summary>
/// <summary>
/// 算法模式
/// 算法模式
...
...
VIZ.H2V.Module/NDIView/Controller/Manual/ManualController.cs
View file @
c4be4b7c
...
@@ -7,6 +7,7 @@ using System.Text;
...
@@ -7,6 +7,7 @@ using System.Text;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
using
VIZ.Framework.Core
;
using
VIZ.H2V.Domain
;
using
VIZ.H2V.Domain
;
using
log4net
;
namespace
VIZ.H2V.Module
namespace
VIZ.H2V.Module
{
{
...
@@ -16,6 +17,11 @@ namespace VIZ.H2V.Module
...
@@ -16,6 +17,11 @@ namespace VIZ.H2V.Module
public
class
ManualController
:
IManualController
public
class
ManualController
:
IManualController
{
{
/// <summary>
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
ManualController
));
/// <summary>
/// 手动控制器
/// 手动控制器
/// </summary>
/// </summary>
/// <param name="support">控制器支持</param>
/// <param name="support">控制器支持</param>
...
@@ -89,7 +95,9 @@ namespace VIZ.H2V.Module
...
@@ -89,7 +95,9 @@ namespace VIZ.H2V.Module
double
x
=
this
.
ClipBoxTargetX
+
this
.
GetMappingValue
();
double
x
=
this
.
ClipBoxTargetX
+
this
.
GetMappingValue
();
x
=
MathHelper
.
Clip
(
min
,
max
,
x
);
x
=
MathHelper
.
Clip
(
min
,
max
,
x
);
this
.
ClipBoxTargetX
=
x
;
this
.
ClipBoxTargetX
=
x
;
return
this
.
ClipBoxSmooth
.
Call
(
this
.
ClipBoxTargetX
,
1
);
double
result
=
this
.
ClipBoxSmooth
.
Call
(
this
.
ClipBoxTargetX
,
1
);
return
result
;
}
}
/// <summary>
/// <summary>
...
...
VIZ.H2V.Module/NDIView/Controller/Recording/NDIViewRecording.cs
View file @
c4be4b7c
...
@@ -7,6 +7,8 @@ using VIZ.Framework.Core;
...
@@ -7,6 +7,8 @@ using VIZ.Framework.Core;
using
VIZ.Framework.Common
;
using
VIZ.Framework.Common
;
using
OpenCvSharp
;
using
OpenCvSharp
;
using
System.Windows.Controls
;
using
System.Windows.Controls
;
using
SharpDX
;
using
log4net
;
namespace
VIZ.H2V.Module
namespace
VIZ.H2V.Module
{
{
...
@@ -15,6 +17,11 @@ namespace VIZ.H2V.Module
...
@@ -15,6 +17,11 @@ namespace VIZ.H2V.Module
/// </summary>
/// </summary>
public
class
NDIViewRecording
:
VideoControlRecording
public
class
NDIViewRecording
:
VideoControlRecording
{
{
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
NDIViewRecording
));
public
NDIViewRecording
()
public
NDIViewRecording
()
{
{
this
.
defaultBoxInfo
=
new
ClipBoxInfo
();
this
.
defaultBoxInfo
=
new
ClipBoxInfo
();
...
@@ -32,32 +39,78 @@ namespace VIZ.H2V.Module
...
@@ -32,32 +39,78 @@ namespace VIZ.H2V.Module
private
ClipBoxInfo
defaultBoxInfo
;
private
ClipBoxInfo
defaultBoxInfo
;
/// <summary>
/// <summary>
/// 保存视频
/// </summary>
/// <param name="path">源路径</param>
/// <param name="path_cut">裁切路径</param>
/// <param name="fps">FPS</param>
/// <param name="width">源视频宽度</param>
/// <param name="height">源视频高度</param>
/// <param name="width_cut">裁切视频宽度</param>
/// <param name="height_cut">裁切视频高度</param>
public
void
Save
(
string
path
,
string
path_cut
,
int
fps
,
int
width
,
int
height
,
int
width_cut
,
int
height_cut
)
{
this
.
IsSaving
=
true
;
using
(
VideoWriter
writer
=
new
VideoWriter
(
path
,
FourCC
.
MJPG
,
fps
,
new
Size
(
width
,
height
)))
using
(
VideoWriter
writer_cut
=
new
VideoWriter
(
path_cut
,
FourCC
.
MJPG
,
fps
,
new
Size
(
width_cut
,
height_cut
)))
{
while
(
this
.
RecordingFrameQueue
.
Count
>
0
)
{
if
(!
this
.
RecordingFrameQueue
.
TryDequeue
(
out
VideoControlRecordingFrame
recording
))
{
Task
.
Delay
(
10
).
Wait
();
continue
;
}
Mat
[]
mats
=
this
.
Packaging
(
recording
);
writer
.
Write
(
mats
[
0
]);
writer_cut
.
Write
(
mats
[
1
]);
mats
[
0
].
Dispose
();
mats
[
1
].
Dispose
();
recording
.
VideoFrame
.
Dispose
();
}
}
this
.
IsSaving
=
false
;
}
/// <summary>
/// 包装
/// 包装
/// </summary>
/// </summary>
/// <param name="recordingFrame">录制帧</param>
/// <param name="recordingFrame">录制帧</param>
public
override
Mat
Packaging
(
VideoControlRecordingFrame
recordingFrame
)
public
Mat
[]
Packaging
(
VideoControlRecordingFrame
recordingFrame
)
{
{
ClipBoxInfo
boxInfo
=
recordingFrame
.
DataFrame
as
ClipBoxInfo
;
ClipBoxInfo
boxInfo
=
recordingFrame
.
DataFrame
as
ClipBoxInfo
;
boxInfo
=
boxInfo
??
this
.
beforeBoxInfo
??
this
.
defaultBoxInfo
;
boxInfo
=
boxInfo
??
this
.
beforeBoxInfo
??
this
.
defaultBoxInfo
;
Mat
mat
=
new
Mat
(
recordingFrame
.
VideoFrame
.
Height
,
recordingFrame
.
VideoFrame
.
Width
,
MatType
.
CV_8UC4
,
recordingFrame
.
VideoFrame
.
DataStream
.
DataPointer
);
Mat
mat
=
new
Mat
(
recordingFrame
.
VideoFrame
.
Height
,
recordingFrame
.
VideoFrame
.
Width
,
MatType
.
CV_8UC4
,
recordingFrame
.
VideoFrame
.
DataStream
.
DataPointer
);
int
x
=
(
int
)
boxInfo
.
SrcRect
.
Left
;
int
y
=
(
int
)
boxInfo
.
SrcRect
.
Top
;
int
w
=
(
int
)(
boxInfo
.
SrcRect
.
Right
-
boxInfo
.
SrcRect
.
Left
);
int
h
=
(
int
)(
boxInfo
.
SrcRect
.
Bottom
-
boxInfo
.
SrcRect
.
Top
);
Mat
cut
=
mat
[
new
Rect
(
x
,
y
,
w
,
h
)];
Mat
dst
=
new
Mat
();
Mat
dst
=
new
Mat
();
Cv2
.
CvtColor
(
cut
,
dst
,
ColorConversionCodes
.
BGRA2BGR
);
Cv2
.
CvtColor
(
mat
,
dst
,
ColorConversionCodes
.
BGRA2BGR
);
int
x
=
(
int
)
boxInfo
.
SrcRect
.
Left
;
int
y
=
0
;
int
w
=
x
+
810
;
int
h
=
1080
;
Mat
cut
=
dst
[
new
Rect
(
x
,
y
,
w
,
h
)];
recordingFrame
.
VideoFrame
.
DataStream
.
Dispose
();
recordingFrame
.
VideoFrame
.
DataStream
.
Dispose
();
mat
.
Dispose
();
mat
.
Dispose
();
cut
.
Dispose
();
this
.
beforeBoxInfo
=
boxInfo
;
this
.
beforeBoxInfo
=
boxInfo
;
return
dst
;
#if DEBUG
log
.
Debug
(
$"x:
{
boxInfo
.
SrcRect
.
Left
}
, timeCode:
{
recordingFrame
.
VideoFrame
.
TimeStamp
}
"
);
#endif
return
new
Mat
[]
{
dst
,
cut
};
}
}
}
}
}
}
VIZ.H2V.Module/NDIView/Controller/Recording/RecordingController.cs
View file @
c4be4b7c
...
@@ -23,7 +23,7 @@ namespace VIZ.H2V.Module
...
@@ -23,7 +23,7 @@ namespace VIZ.H2V.Module
{
{
this
.
Support
=
support
;
this
.
Support
=
support
;
this
.
Recording
=
new
NDIViewRecording
();
this
.
Recording
=
new
NDIViewRecording
();
this
.
Recording
.
MaxFrameCount
=
3
0
*
25
;
this
.
Recording
.
MaxFrameCount
=
6
0
*
25
;
Single
=
this
;
Single
=
this
;
}
}
...
@@ -34,7 +34,7 @@ namespace VIZ.H2V.Module
...
@@ -34,7 +34,7 @@ namespace VIZ.H2V.Module
public
IRecordingSupport
Support
{
get
;
private
set
;
}
public
IRecordingSupport
Support
{
get
;
private
set
;
}
/// <summary>
/// <summary>
/// NDI视频录制
/// NDI视频录制
裁切
/// </summary>
/// </summary>
private
NDIViewRecording
Recording
;
private
NDIViewRecording
Recording
;
...
@@ -58,9 +58,10 @@ namespace VIZ.H2V.Module
...
@@ -58,9 +58,10 @@ namespace VIZ.H2V.Module
{
{
Directory
.
CreateDirectory
(
dir
);
Directory
.
CreateDirectory
(
dir
);
}
}
string
path
=
Path
.
Combine
(
dir
,
$"
{
DateTime
.
Now
.
ToString
(
"yyyy_MM_dd__HH_mm_ss"
)}
.avi"
);
string
path
=
Path
.
Combine
(
dir
,
$"
{
DateTime
.
Now
.
ToString
(
"yyyy_MM_dd__HH_mm_ss__SRC"
)}
.avi"
);
string
path_cut
=
Path
.
Combine
(
dir
,
$"
{
DateTime
.
Now
.
ToString
(
"yyyy_MM_dd__HH_mm_ss__CUT"
)}
.avi"
);
this
.
Recording
.
Save
(
path
,
25
,
810
,
1080
);
this
.
Recording
.
Save
(
path
,
path_cut
,
25
,
1920
,
1080
,
810
,
1080
);
}
}
}
}
}
}
VIZ.H2V.Module/NDIView/VieweModel/NDIViewModel.Command.cs
View file @
c4be4b7c
...
@@ -74,10 +74,10 @@ namespace VIZ.H2V.Module
...
@@ -74,10 +74,10 @@ namespace VIZ.H2V.Module
#if DEBUG
#if DEBUG
// ====================================================================
// ====================================================================
// 录制测试
// 录制测试
//
if (this.ViewKey == NDIViewKeys.CAM_1)
if
(
this
.
ViewKey
==
NDIViewKeys
.
CAM_1
)
//
{
{
//
this.ReecordingController = new RecordingController(this);
this
.
ReecordingController
=
new
RecordingController
(
this
);
//
}
}
// ====================================================================
// ====================================================================
#endif
#endif
}
}
...
...
VIZ.H2V.Module/NDIView/VieweModel/NDIViewModel.Manual_NDI.cs
View file @
c4be4b7c
...
@@ -39,8 +39,7 @@ namespace VIZ.H2V.Module
...
@@ -39,8 +39,7 @@ namespace VIZ.H2V.Module
return
;
return
;
}
}
this
.
ClipBoxX
=
this
.
GetClipX
(
renderInfo
);
this
.
ManualController
.
Reset
(
this
.
ClipBoxX
);
this
.
ManualController
.
Reset
(
this
.
ClipBoxX
.
Value
);
}
}
/// <summary>
/// <summary>
...
@@ -85,7 +84,7 @@ namespace VIZ.H2V.Module
...
@@ -85,7 +84,7 @@ namespace VIZ.H2V.Module
ClipBoxInfo
clipBox
=
new
ClipBoxInfo
();
ClipBoxInfo
clipBox
=
new
ClipBoxInfo
();
clipBox
.
DrawingBorderWidth
=
this
.
CLIP_BOX_BORDER_WIDTH
;
clipBox
.
DrawingBorderWidth
=
this
.
CLIP_BOX_BORDER_WIDTH
;
clipBox
.
SrcRect
=
new
RawRectangleF
((
float
)(
this
.
ClipBoxX
??
0
),
0
,
(
float
)(
this
.
ClipBoxX
??
0
)
+
(
float
)
this
.
CLIP_BOX_WIDTH
,
renderInfo
.
Frame
.
Height
);
clipBox
.
SrcRect
=
new
RawRectangleF
((
float
)(
this
.
ClipBoxX
),
0
,
(
float
)(
this
.
ClipBoxX
)
+
(
float
)
this
.
CLIP_BOX_WIDTH
,
renderInfo
.
Frame
.
Height
);
clipBox
.
DrawingBorderColor
=
this
.
StrategyMode
==
AlgorithmStrategyMode
.
manual_mode
?
this
.
ClipBoxStrokeColor_Manual
:
this
.
ClipBoxStrokeColor_Normal
;
clipBox
.
DrawingBorderColor
=
this
.
StrategyMode
==
AlgorithmStrategyMode
.
manual_mode
?
this
.
ClipBoxStrokeColor_Manual
:
this
.
ClipBoxStrokeColor_Normal
;
clipBox
.
MaskColor
=
this
.
CLIP_BOX_MASK_COLOR
;
clipBox
.
MaskColor
=
this
.
CLIP_BOX_MASK_COLOR
;
...
@@ -111,12 +110,12 @@ namespace VIZ.H2V.Module
...
@@ -111,12 +110,12 @@ namespace VIZ.H2V.Module
#if DEBUG
#if DEBUG
// ====================================================================
// ====================================================================
// 录制测试
// 录制测试
//
if (this.ReecordingController != null)
if
(
this
.
ReecordingController
!=
null
)
//
{
{
//
ClipBoxInfo temp = new ClipBoxInfo();
ClipBoxInfo
temp
=
new
ClipBoxInfo
();
// temp.SrcRect = new RawRectangleF((float)(this.ClipBoxX ?? 555), 0, (float)((this.ClipBoxX ?? 555) + 810)
, 1080);
temp
.
SrcRect
=
new
RawRectangleF
((
float
)
this
.
ClipBoxX
,
0
,
(
float
)
this
.
ClipBoxX
+
810
,
1080
);
//
this.ReecordingController.Append(e.Frame, temp);
this
.
ReecordingController
.
Append
(
e
.
Frame
,
temp
);
//
}
}
// ====================================================================
// ====================================================================
#endif
#endif
...
@@ -147,21 +146,5 @@ namespace VIZ.H2V.Module
...
@@ -147,21 +146,5 @@ namespace VIZ.H2V.Module
// 统计裁切FPS
// 统计裁切FPS
this
.
ClipFPS
.
CalcFps
();
this
.
ClipFPS
.
CalcFps
();
}
}
/// <summary>
/// 获取默认的裁切坐标
/// </summary>
/// <param name="renderInfo">渲染信息</param>
/// <returns>默认裁切坐标</returns>
private
double
GetClipX
(
VideoRenderInfo
renderInfo
)
{
if
(
this
.
ClipBoxX
!=
null
)
return
this
.
ClipBoxX
.
Value
;
if
(
renderInfo
==
null
||
renderInfo
.
Frame
==
null
)
return
0d
;
return
(
renderInfo
.
Frame
.
Width
-
this
.
CLIP_BOX_WIDTH
)
/
2d
;
}
}
}
}
}
VIZ.H2V.Module/NDIView/VieweModel/NDIViewModel.Property.cs
View file @
c4be4b7c
...
@@ -264,11 +264,11 @@ namespace VIZ.H2V.Module
...
@@ -264,11 +264,11 @@ namespace VIZ.H2V.Module
#
region
ClipBoxX
--
裁切框
X
坐标
#
region
ClipBoxX
--
裁切框
X
坐标
private
double
?
clipBoxX
=
555
;
private
double
clipBoxX
=
555
;
/// <summary>
/// <summary>
/// 裁切框X坐标
/// 裁切框X坐标
/// </summary>
/// </summary>
public
double
?
ClipBoxX
public
double
ClipBoxX
{
{
get
{
return
clipBoxX
;
}
get
{
return
clipBoxX
;
}
set
{
clipBoxX
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
ClipBoxX
));
}
set
{
clipBoxX
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
ClipBoxX
));
}
...
...
VIZ.H2V.Module/NDIView/VieweModel/NDIViewModel.cs
View file @
c4be4b7c
...
@@ -231,7 +231,7 @@ namespace VIZ.H2V.Module
...
@@ -231,7 +231,7 @@ namespace VIZ.H2V.Module
if
(
renderInfo
==
null
)
if
(
renderInfo
==
null
)
return
null
;
return
null
;
return
new
List
<
int
>
{
(
int
)
(
this
.
ClipBoxX
??
0
),
0
,
(
int
)((
this
.
ClipBoxX
??
0
)
+
this
.
CLIP_BOX_WIDTH
),
renderInfo
.
Frame
.
Height
};
return
new
List
<
int
>
{
(
int
)
this
.
ClipBoxX
,
0
,
(
int
)(
this
.
ClipBoxX
+
this
.
CLIP_BOX_WIDTH
),
renderInfo
.
Frame
.
Height
};
}
}
/// <summary>
/// <summary>
...
...
VIZ.H2V/App.xaml.cs
View file @
c4be4b7c
...
@@ -41,7 +41,7 @@ namespace VIZ.H2V
...
@@ -41,7 +41,7 @@ namespace VIZ.H2V
#if DEBUG
#if DEBUG
// ====================================================================
// ====================================================================
// 录制测试
// 录制测试
//
AppSetup.AppendSetup(new AppSetup_Recording());
AppSetup
.
AppendSetup
(
new
AppSetup_Recording
());
// ====================================================================
// ====================================================================
#endif
#endif
...
...
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