update source comments of examples

pull/3471/head
kallaballa 2 years ago
parent 4492d8e1b2
commit baea51bf41
  1. 14
      modules/v4d/samples/custom_source_and_sink.cpp
  2. 7
      modules/v4d/samples/display_image.cpp
  3. 10
      modules/v4d/samples/display_image_fb.cpp
  4. 3
      modules/v4d/samples/font_rendering.cpp
  5. 3
      modules/v4d/samples/font_with_gui.cpp
  6. 4
      modules/v4d/samples/render_opengl.cpp
  7. 7
      modules/v4d/samples/vector_graphics.cpp
  8. 4
      modules/v4d/samples/vector_graphics_and_fb.cpp
  9. 8
      modules/v4d/samples/video_editing.cpp

@ -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();
});
}

@ -5,10 +5,12 @@ using namespace cv;
using namespace cv::v4d;
int main() {
//Creates a V4D window for on screen rendering
//Creates a V4D window for on screen rendering with a window size of 720p and a framebuffer of the same size.
//Please note that while the window size may change the framebuffer size may not. If you need multiple framebuffer
//sizes you need multiple V4D objects
Ptr<V4D> window = V4D::make(Size(1280, 720), cv::Size(), "Display image");
//An image
//Load an image
#ifdef __EMSCRIPTEN__
Mat image = read_embedded_image("doc/lena.png");
#else
@ -21,6 +23,7 @@ int main() {
window->run([=](){
//Feeds the image to the video pipeline
window->feed(image);
//Displays the framebuffer in the window. Returns false if the windows has been closed.
return window->display();
});
}

@ -5,15 +5,16 @@ using namespace cv;
using namespace cv::v4d;
int main() {
//Creates a V4D object for on screen rendering
//Creates a V4D object
Ptr<V4D> window = V4D::make(Size(1280, 720), cv::Size(), "Display image and FB");
//Read an image as UMat
//Loads an image as a UMat (just in case we have hardware acceleration available)
#ifdef __EMSCRIPTEN__
UMat image = read_embedded_image("doc/lena.png").getUMat(ACCESS_READ);
#else
UMat image = imread(samples::findFile("lena.jpg")).getUMat(ACCESS_READ);
#endif
//We have to manually resize and color convert the image when using direct frambuffer access.
UMat resized;
UMat converted;
resize(image, resized, window->framebufferSize());
@ -21,7 +22,10 @@ int main() {
//Display the framebuffer in the native window in an endless loop
window->run([=](){
window->fb([&](UMat& framebuffer){
//Create a fb context and copy the prepared image to the framebuffer. The fb context
//takes care of retrieving a storing the data on the graphics card (using CL-GL
//interop if available), ready for other contexts to use
window->fb([&](UMat& framebuffer){
converted.copyTo(framebuffer);
});
return window->display();

@ -9,9 +9,8 @@ int main() {
//The text to render
string hw = "Hello World";
//Display the framebuffer in the native window in an endless loop
window->run([=](){
//Render the text at the center of the screen
//Render the text at the center of the screen. Note that you can load you own fonts.
window->nvg([&](const Size& sz) {
using namespace cv::v4d::nvg;
clear();

@ -25,7 +25,7 @@ int main() {
});
window->run([&]() {
//Render the text at the center of the screen
//Render the text at the center of the screen using parameters from the GUI.
window->nvg([&](const Size& sz) {
using namespace cv::v4d::nvg;
clear();
@ -36,7 +36,6 @@ int main() {
text(sz.width / 2.0, sz.height / 2.0, hw.c_str(), hw.c_str() + hw.size());
});
//Display the framebuffer in the native window
return window->display();
});
}

@ -12,12 +12,10 @@ int main() {
});
window->run([=]() {
window->gl([]() {
//Clears the screen
//Clears the screen. The clear color and other GL-states are preserved between context-calls.
glClear(GL_COLOR_BUFFER_BIT);
});
//If onscreen rendering is enabled it displays the framebuffer in the native window.
//Returns false if the window was closed.
return window->display();
});
}

@ -6,11 +6,12 @@ using namespace cv::v4d;
int main() {
Ptr<V4D> window = V4D::make(Size(1280, 720), cv::Size(), "Vector Graphics");
//Render the framebuffer in the native window in an endless loop
window->run([=]() {
//Creates a NanoVG context and draws eyes
//Creates a NanoVG context and draws googly eyes that occasionally blink.
window->nvg([](const Size& sz) {
//Calls from this namespace may only be used inside a nvg context
//Calls from this namespace may only be used inside a nvg context.
//Nvg calls work exactly like their c-funtion counterparts.
//Please refer to the NanoVG documentation for details.
using namespace cv::v4d::nvg;
clear();

@ -7,9 +7,8 @@ using namespace cv::v4d;
int main() {
Ptr<V4D> window = V4D::make(Size(1280, 720), cv::Size(), "Vector Graphics and Framebuffer");
//Render the framebuffer in the native window in an endless loop
window->run([=]() {
//Creates a NanoVG context and draws eyes
//Again creates a NanoVG context and draws googly eyes
window->nvg([](const Size& sz) {
//Calls from this namespace may only be used inside a nvg context
using namespace cv::v4d::nvg;
@ -93,6 +92,7 @@ int main() {
fill();
});
//Provides the framebuffer as left-off by the nvg context.
window->fb([](UMat& framebuffer) {
//Heavily blurs the eyes using a cheap boxFilter
boxFilter(framebuffer, framebuffer, -1, Size(15, 15), Point(-1,-1), true, BORDER_REPLICATE);

@ -31,10 +31,11 @@ int main(int argc, char** argv) {
#endif
window->run([=]() {
//Capture video from the Source
//Capture video from the source
if(!window->capture())
return false; //end of input video
//Render on top of the video
window->nvg([=](const Size& sz) {
using namespace cv::v4d::nvg;
@ -45,9 +46,10 @@ int main(int argc, char** argv) {
text(sz.width / 2.0, sz.height / 2.0, hv.c_str(), hv.c_str() + hv.size());
});
window->write(); //Write video to the Sink
//Write video to the sink (do nothing in case of WebAssembly)
window->write();
return window->display(); //Display the framebuffer in the native window
return window->display();
});
} catch(std::exception& ex) {
cerr << ex.what() << endl;

Loading…
Cancel
Save