parent
a403a0bbe0
commit
55592b3dcb
28 changed files with 188 additions and 191 deletions
@ -1,30 +1,27 @@ |
||||
#include <opencv2/v4d/v4d.hpp> |
||||
#include <opencv2/imgcodecs.hpp> |
||||
|
||||
#ifdef __EMSCRIPTEN__ |
||||
# include <fstream> |
||||
#endif |
||||
using namespace cv; |
||||
using namespace cv::v4d; |
||||
|
||||
int main() { |
||||
using namespace cv; |
||||
using namespace cv::v4d; |
||||
//Creates a V4D window for on screen rendering
|
||||
static Ptr<V4D> window = V4D::make(Size(1280, 720), "Show image"); |
||||
|
||||
//Creates a V4D object for on screen rendering
|
||||
Ptr<V4D> v4d = V4D::make(Size(1280, 720), "Show image"); |
||||
v4d->setVisible(true); |
||||
int main() { |
||||
//An image
|
||||
#ifdef __EMSCRIPTEN__ |
||||
Mat image = read_image("doc/lena.png"); |
||||
#else |
||||
Mat image = imread(samples::findFile("lena.jpg")); |
||||
#endif |
||||
//Feeds the image to the video pipeline
|
||||
window->feed(image); |
||||
//Display the framebuffer in the native window in an endless loop.
|
||||
//V4D::run() though it takes a functor is not a context. It is simply an abstraction
|
||||
//of a run loop for portability reasons and executes the functor until the application
|
||||
//terminates or the functor returns false.
|
||||
v4d->run([=](){ |
||||
//Feeds the image to the video pipeline
|
||||
v4d->feed(image); |
||||
return v4d->display(); |
||||
window->run([=](){ |
||||
updateFps(window, true); |
||||
return window->display(); |
||||
}); |
||||
} |
||||
|
@ -1,30 +1,28 @@ |
||||
#include <opencv2/v4d/v4d.hpp> |
||||
|
||||
int main() { |
||||
using namespace cv; |
||||
using namespace cv::v4d; |
||||
using namespace cv; |
||||
using namespace cv::v4d; |
||||
|
||||
Ptr<V4D> v4d = V4D::make(Size(1280, 720), "Font Rendering"); |
||||
v4d->setVisible(true); |
||||
static Ptr<V4D> window = V4D::make(Size(1280, 720), "Font Rendering"); |
||||
|
||||
int main() { |
||||
//The text to render
|
||||
string hw = "Hello World"; |
||||
//Clear with black
|
||||
v4d->clear(); |
||||
//Render the text at the center of the screen
|
||||
v4d->nvg([&](const Size& sz) { |
||||
using namespace cv::v4d::nvg; |
||||
fontSize(40.0f); |
||||
fontFace("sans-bold"); |
||||
fillColor(Scalar(255, 0, 0, 255)); |
||||
textAlign(NVG_ALIGN_CENTER | NVG_ALIGN_TOP); |
||||
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
|
||||
v4d->run([=](){ |
||||
updateFps(v4d,true); |
||||
return v4d->display(); |
||||
window->run([=](){ |
||||
window->clear(); |
||||
//Render the text at the center of the screen
|
||||
window->nvg([&](const Size& sz) { |
||||
using namespace cv::v4d::nvg; |
||||
fontSize(40.0f); |
||||
fontFace("sans-bold"); |
||||
fillColor(Scalar(255, 0, 0, 255)); |
||||
textAlign(NVG_ALIGN_CENTER | NVG_ALIGN_TOP); |
||||
text(sz.width / 2.0, sz.height / 2.0, hw.c_str(), hw.c_str() + hw.size()); |
||||
}); |
||||
updateFps(window,true); |
||||
return window->display(); |
||||
}); |
||||
} |
||||
|
||||
|
@ -1,23 +1,24 @@ |
||||
#include <opencv2/v4d/v4d.hpp> |
||||
|
||||
int main() { |
||||
using namespace cv; |
||||
using namespace cv::v4d; |
||||
using namespace cv; |
||||
using namespace cv::v4d; |
||||
|
||||
Ptr<V4D> v4d = V4D::make(Size(1280, 720), "GL Blue Screen", true); |
||||
v4d->printSystemInfo(); |
||||
v4d->setVisible(true); |
||||
static Ptr<V4D> window = V4D::make(Size(1280, 720), "GL Blue Screen"); |
||||
|
||||
v4d->run([=]() { |
||||
v4d->gl([]() { |
||||
//Clears the screen blue
|
||||
glClearColor(0.0f, 0.0f, 1.0f, 1.0f); |
||||
int main() { |
||||
window->gl([](){ |
||||
//Sets blue as clear color
|
||||
glClearColor(0.0f, 0.0f, 1.0f, 1.0f); |
||||
}); |
||||
window->run([=]() { |
||||
window->gl([]() { |
||||
//Clears the screen
|
||||
glClear(GL_COLOR_BUFFER_BIT); |
||||
}); |
||||
updateFps(v4d,true); |
||||
updateFps(window,true); |
||||
//If onscreen rendering is enabled it displays the framebuffer in the native window.
|
||||
//Returns false if the window was closed.
|
||||
return v4d->display(); |
||||
return window->display(); |
||||
}); |
||||
} |
||||
|
||||
|
Loading…
Reference in new issue