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