@@ -10,9 +10,11 @@ import core.stdc.stdlib;
10
10
11
11
import dcv.videoio;
12
12
import dcv.imgproc.color;
13
- import dcv.core.utils ;
13
+ import dcv.core;
14
14
import dcv.plot.figure;
15
15
16
+ import mir.ndslice;
17
+
16
18
// executable -l "video=Lenovo EasyCamera"
17
19
// executable -f ../data/centaur_1.mpg
18
20
@@ -26,7 +28,8 @@ void main(string[] args)
26
28
27
29
// ////////// Open the video stream ////////////////
28
30
29
- InputStream inStream = new InputStream ;
31
+ InputStream inStream = mallocNew! InputStream ;
32
+ scope (exit) destroyFree (inStream);
30
33
31
34
string path; // path to the video
32
35
InputStreamType type; // type of the stream (file or live)
@@ -38,16 +41,9 @@ void main(string[] args)
38
41
return ;
39
42
}
40
43
41
- try
42
- {
43
- // Open the example video
44
- inStream.open(path, type);
45
- }
46
- catch (Exception e)
47
- {
48
- writeln(" Cannot open input video stream: " ~ e.message);
49
- exit(- 1 );
50
- }
44
+ inStream.setVideoSizeRequest(640 , 480 );
45
+ // Open the example video
46
+ inStream.open(path, type);
51
47
52
48
// Check if video has been opened correctly
53
49
if (! inStream.isOpen)
@@ -68,6 +64,8 @@ void main(string[] args)
68
64
StopWatch s;
69
65
s.start;
70
66
67
+ auto fig = imshow(rcslice! ubyte (480 , 640 , 3 ), path);
68
+
71
69
// Read each next frame of the video in the loop.
72
70
while (inStream.readFrame(frame))
73
71
{
@@ -76,11 +74,14 @@ void main(string[] args)
76
74
s.reset;
77
75
78
76
// If video frame pixel format is YUV, convert the data to RGB, then show it on screen
79
- if (frame.format == ImageFormat.IF_YUV )
80
- frame.sliced.yuv2rgb! ubyte .imshow(path);
81
- else
82
- frame.imshow(path);
83
-
77
+ if (frame.format == ImageFormat.IF_YUV ){
78
+ auto toShow = frame.sliced.yuv2rgb! ubyte ;
79
+ fig.draw(toShow, ImageFormat.IF_RGB );
80
+ }else
81
+ fig.draw(frame);
82
+
83
+ destroyFree(frame);
84
+ frame = null ;
84
85
// Compensate fps wait for lost time on color conversion.
85
86
int wait = max(1 , cast (int )waitFrame - cast (int )s.peek.total! " msecs" );
86
87
@@ -96,7 +97,7 @@ void main(string[] args)
96
97
So, if user presses the 'x' button, normal behavior would be to break the
97
98
streaming loop.
98
99
*/
99
- if (! figure(path) .visible)
100
+ if (! fig .visible)
100
101
break ;
101
102
}
102
103
0 commit comments