diff --git a/modules/viz2d/samples/cpp/font_rendering.cpp b/modules/viz2d/samples/cpp/font_rendering.cpp index 844885ed7..81125c36a 100644 --- a/modules/viz2d/samples/cpp/font_rendering.cpp +++ b/modules/viz2d/samples/cpp/font_rendering.cpp @@ -21,7 +21,7 @@ int main(int argc, char** argv) { fontFace("sans-bold"); fillColor(Scalar(255, 0, 0, 255)); textAlign(NVG_ALIGN_CENTER | NVG_ALIGN_TOP); - text(WIDTH / 2.0, HEIGHT / 2.0, hw.c_str(), hw.c_str() + hw.size()); + text(sz.width / 2.0, sz.height / 2.0, hw.c_str(), hw.c_str() + hw.size()); }); //Display the framebuffer in the native window in an endless loop diff --git a/modules/viz2d/samples/cpp/font_with_gui.cpp b/modules/viz2d/samples/cpp/font_with_gui.cpp index 89488bc7d..78fa68343 100644 --- a/modules/viz2d/samples/cpp/font_with_gui.cpp +++ b/modules/viz2d/samples/cpp/font_with_gui.cpp @@ -36,7 +36,7 @@ int main(int argc, char** argv) { fontFace("sans-bold"); fillColor(Scalar(textColor.b() * 255, textColor.g() * 255, textColor.r() * 255, 255)); textAlign(NVG_ALIGN_CENTER | NVG_ALIGN_TOP); - text(WIDTH / 2.0, HEIGHT / 2.0, hw.c_str(), hw.c_str() + hw.size()); + text(sz.width / 2.0, sz.height / 2.0, hw.c_str(), hw.c_str() + hw.size()); }); return v2d->display(); }); diff --git a/modules/viz2d/samples/cpp/vector_graphics.cpp b/modules/viz2d/samples/cpp/vector_graphics.cpp index f07d9b2ec..ce425903d 100644 --- a/modules/viz2d/samples/cpp/vector_graphics.cpp +++ b/modules/viz2d/samples/cpp/vector_graphics.cpp @@ -16,10 +16,10 @@ int main(int argc, char** argv) { beginPath(); strokeWidth(3.0); strokeColor(Scalar(0,0,255,255)); //BGRA - moveTo(WIDTH/2.0, 0); - lineTo(WIDTH/2.0, HEIGHT); - moveTo(0, HEIGHT/2.0); - lineTo(WIDTH, HEIGHT/2.0); + moveTo(sz.width/2.0, 0); + lineTo(sz.width/2.0, sz.height); + moveTo(0, sz.height/2.0); + lineTo(sz.width, sz.height/2.0); stroke(); }); diff --git a/modules/viz2d/samples/cpp/vector_graphics_and_fb.cpp b/modules/viz2d/samples/cpp/vector_graphics_and_fb.cpp index a2cf79ac1..c65639783 100644 --- a/modules/viz2d/samples/cpp/vector_graphics_and_fb.cpp +++ b/modules/viz2d/samples/cpp/vector_graphics_and_fb.cpp @@ -16,10 +16,10 @@ int main(int argc, char** argv) { beginPath(); strokeWidth(3.0); strokeColor(Scalar(0,0,255,255)); //BGRA - moveTo(WIDTH/2.0, 0); - lineTo(WIDTH/2.0, HEIGHT); - moveTo(0, HEIGHT/2.0); - lineTo(WIDTH, HEIGHT/2.0); + moveTo(sz.width/2.0, 0); + lineTo(sz.width/2.0, sz.height); + moveTo(0, sz.height/2.0); + lineTo(sz.width, sz.height/2.0); stroke(); }); diff --git a/modules/viz2d/samples/cpp/video_editing.cpp b/modules/viz2d/samples/cpp/video_editing.cpp index 127dda76f..5f07a6f71 100644 --- a/modules/viz2d/samples/cpp/video_editing.cpp +++ b/modules/viz2d/samples/cpp/video_editing.cpp @@ -21,7 +21,8 @@ int main(int argc, char** argv) { v2d->run([=]() { if(!v2d->capture()) - return false; + return false; //end of input video + v2d->nvg([=](const Size& sz) { using namespace cv::viz::nvg; @@ -29,10 +30,10 @@ int main(int argc, char** argv) { fontFace("sans-bold"); fillColor(Scalar(255, 0, 0, 255)); textAlign(NVG_ALIGN_CENTER | NVG_ALIGN_TOP); - text(WIDTH / 2.0, HEIGHT / 2.0, hv.c_str(), hv.c_str() + hv.size()); + text(sz.width / 2.0, sz.height / 2.0, hv.c_str(), hv.c_str() + hv.size()); }); - v2d->write(); - return v2d->display(); + v2d->write(); //write the output video + return v2d->display(); //display the framebuffer in the native window }); }