Skip to content

breaking changes nogc part 1 #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
{
"mir-algorithm": ">=3.15.3",
"mir-random": "2.2.19",
"mir-core": "~>1.5.3",
"bcaa": "~>0.0.8",
"dvector": "~>0.0.5",
"dplug:core": "~>13.4.9"
Expand Down
37 changes: 19 additions & 18 deletions examples/video/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import core.stdc.stdlib;

import dcv.videoio;
import dcv.imgproc.color;
import dcv.core.utils;
import dcv.core;
import dcv.plot.figure;

import mir.ndslice;

// executable -l "video=Lenovo EasyCamera"
// executable -f ../data/centaur_1.mpg

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

//////////// Open the video stream ////////////////

InputStream inStream = new InputStream;
InputStream inStream = mallocNew!InputStream;
scope(exit) destroyFree(inStream);

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

try
{
// Open the example video
inStream.open(path, type);
}
catch(Exception e)
{
writeln("Cannot open input video stream: " ~ e.message);
exit(-1);
}
inStream.setVideoSizeRequest(640, 480);
// Open the example video
inStream.open(path, type);

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

auto fig = imshow(rcslice!ubyte(480, 640, 3), path);

// Read each next frame of the video in the loop.
while (inStream.readFrame(frame))
{
Expand All @@ -76,11 +74,14 @@ void main(string[] args)
s.reset;

// If video frame pixel format is YUV, convert the data to RGB, then show it on screen
if (frame.format == ImageFormat.IF_YUV)
frame.sliced.yuv2rgb!ubyte.imshow(path);
else
frame.imshow(path);

if (frame.format == ImageFormat.IF_YUV){
auto toShow = frame.sliced.yuv2rgb!ubyte;
fig.draw(toShow, ImageFormat.IF_RGB);
}else
fig.draw(frame);

destroyFree(frame);
frame = null;
// Compensate fps wait for lost time on color conversion.
int wait = max(1, cast(int)waitFrame - cast(int)s.peek.total!"msecs");

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

Expand Down
Binary file added examples/video/video.pdb
Binary file not shown.
Loading