Skip to content

Commit e154d47

Browse files
authored
Merge pull request #155 from aferust/master
breaking changes nogc part 1
2 parents bc0a8ca + 33fd882 commit e154d47

File tree

18 files changed

+334
-491
lines changed

18 files changed

+334
-491
lines changed

dub.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
{
3939
"mir-algorithm": ">=3.15.3",
4040
"mir-random": "2.2.19",
41+
"mir-core": "~>1.5.3",
4142
"bcaa": "~>0.0.8",
4243
"dvector": "~>0.0.5",
4344
"dplug:core": "~>13.4.9"

examples/video/source/app.d

+19-18
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import core.stdc.stdlib;
1010

1111
import dcv.videoio;
1212
import dcv.imgproc.color;
13-
import dcv.core.utils;
13+
import dcv.core;
1414
import dcv.plot.figure;
1515

16+
import mir.ndslice;
17+
1618
// executable -l "video=Lenovo EasyCamera"
1719
// executable -f ../data/centaur_1.mpg
1820

@@ -26,7 +28,8 @@ void main(string[] args)
2628

2729
//////////// Open the video stream ////////////////
2830

29-
InputStream inStream = new InputStream;
31+
InputStream inStream = mallocNew!InputStream;
32+
scope(exit) destroyFree(inStream);
3033

3134
string path; // path to the video
3235
InputStreamType type; // type of the stream (file or live)
@@ -38,16 +41,9 @@ void main(string[] args)
3841
return;
3942
}
4043

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);
5147

5248
// Check if video has been opened correctly
5349
if (!inStream.isOpen)
@@ -68,6 +64,8 @@ void main(string[] args)
6864
StopWatch s;
6965
s.start;
7066

67+
auto fig = imshow(rcslice!ubyte(480, 640, 3), path);
68+
7169
// Read each next frame of the video in the loop.
7270
while (inStream.readFrame(frame))
7371
{
@@ -76,11 +74,14 @@ void main(string[] args)
7674
s.reset;
7775

7876
// 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;
8485
// Compensate fps wait for lost time on color conversion.
8586
int wait = max(1, cast(int)waitFrame - cast(int)s.peek.total!"msecs");
8687

@@ -96,7 +97,7 @@ void main(string[] args)
9697
So, if user presses the 'x' button, normal behavior would be to break the
9798
streaming loop.
9899
*/
99-
if (!figure(path).visible)
100+
if (!fig.visible)
100101
break;
101102
}
102103

examples/video/video.pdb

8.32 MB
Binary file not shown.

0 commit comments

Comments
 (0)