|
|
|
@ -10,7 +10,7 @@ int main() { |
|
|
|
|
Ptr<V4D> window = V4D::make(Size(1280, 720), cv::Size(), "Custom Source/Sink"); |
|
|
|
|
|
|
|
|
|
string hr = "Hello Rainbow!"; |
|
|
|
|
//Make a Source that generates rainbow frames.
|
|
|
|
|
//Make a source that generates rainbow frames.
|
|
|
|
|
Source src([](cv::UMat& frame){ |
|
|
|
|
static long cnt = 0; |
|
|
|
|
//The source is responsible for initializing the frame..
|
|
|
|
@ -20,7 +20,7 @@ int main() { |
|
|
|
|
return true; |
|
|
|
|
}, 60.0f); |
|
|
|
|
|
|
|
|
|
//Make a Sink the saves each frame to a PNG file.
|
|
|
|
|
//Make a sink the saves each frame to a PNG file (does nothing in case of WebAssembly).
|
|
|
|
|
Sink sink([](const cv::UMat& frame){ |
|
|
|
|
try { |
|
|
|
|
#ifndef __EMSCRIPTEN__ |
|
|
|
@ -41,11 +41,10 @@ int main() { |
|
|
|
|
window->setSink(sink); |
|
|
|
|
|
|
|
|
|
window->run([=]() { |
|
|
|
|
//Capture video from the Source
|
|
|
|
|
if(!window->capture()) |
|
|
|
|
return false; //end of input video
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
//Render "Hello Rainbow!" over the frame
|
|
|
|
|
//Render "Hello Rainbow!" over the video
|
|
|
|
|
window->nvg([=](const Size& sz) { |
|
|
|
|
using namespace cv::v4d::nvg; |
|
|
|
|
|
|
|
|
@ -56,8 +55,9 @@ int main() { |
|
|
|
|
text(sz.width / 2.0, sz.height / 2.0, hr.c_str(), hr.c_str() + hr.size()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
window->write(); //Write video to the Sink
|
|
|
|
|
return window->display(); //Display the framebuffer in the native window
|
|
|
|
|
window->write(); |
|
|
|
|
|
|
|
|
|
return window->display(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|