refactoring, renaming and commenting

pull/3471/head
kallaballa 2 years ago
parent 781cc2f5e3
commit 00d0691d97
  1. 2
      modules/viz2d/include/opencv2/viz2d/util.hpp
  2. 15
      modules/viz2d/include/opencv2/viz2d/viz2d.hpp
  3. 4
      modules/viz2d/samples/cpp/beauty/beauty-demo.cpp
  4. 4
      modules/viz2d/samples/cpp/font/font-demo.cpp
  5. 2
      modules/viz2d/samples/cpp/nanovg/nanovg-demo.cpp
  6. 6
      modules/viz2d/samples/cpp/optflow/optflow-demo.cpp
  7. 4
      modules/viz2d/samples/cpp/pedestrian/pedestrian-demo.cpp
  8. 4
      modules/viz2d/samples/cpp/shader/shader-demo.cpp
  9. 4
      modules/viz2d/samples/cpp/tetra/tetra-demo.cpp
  10. 4
      modules/viz2d/samples/cpp/video/video-demo.cpp
  11. 2
      modules/viz2d/src/util.cpp
  12. 5
      modules/viz2d/src/viz2d.cpp

@ -53,7 +53,7 @@ CV_EXPORTS void print_system_info();
* using #install_signal_handlers()
* @return true if the program should keep on running
*/
CV_EXPORTS bool keep_running();
CV_EXPORTS bool keepRunning();
/*!
* Little helper function to keep track of FPS and optionally display it using NanoVG

@ -149,7 +149,7 @@ public:
* @param samples MSAA samples.
* @param debug Create a debug OpenGL context.
*/
CV_EXPORTS Viz2D(const cv::Size& initialSize, const cv::Size& frameBufferSize, bool offscreen,
CV_EXPORTS static cv::Ptr<Viz2D> make(const cv::Size& initialSize, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major = 4, int minor = 6, int samples = 0, bool debug = false);
/*!
* Default destructor
@ -386,6 +386,19 @@ public:
*/
CV_EXPORTS bool display();
private:
/*!
* Creates a Viz2D object which is the central object to perform visualizations with.
* @param initialSize The initial size of the heavy-weight window.
* @param frameBufferSize The initial size of the framebuffer backing the window (needs to be equal or greate then initial size).
* @param offscreen Don't create a window and rather render offscreen.
* @param title The window title.
* @param major The OpenGL major version to request.
* @param minor The OpenGL minor version to request.
* @param samples MSAA samples.
* @param debug Create a debug OpenGL context.
*/
CV_EXPORTS Viz2D(const cv::Size& initialSize, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major = 4, int minor = 6, int samples = 0, bool debug = false);
void setDefaultKeyboardEventCallback();
void setKeyboardEventCallback(
std::function<bool(int key, int scancode, int action, int modifiers)> fn);

@ -48,7 +48,7 @@ bool side_by_side = false;
bool stretch = false;
#endif
static cv::Ptr<cv::viz::Viz2D> v2d = new cv::viz::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Beauty Demo");
static cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Beauty Demo");
static cv::Ptr<cv::face::Facemark> facemark = cv::face::createFacemarkLBF();
#ifdef USE_TRACKER
static cv::Ptr<cv::Tracker> tracker = cv::TrackerKCF::create();
@ -391,7 +391,7 @@ int main(int argc, char **argv) {
Sink sink = make_writer_sink(OUTPUT_FILENAME, cv::VideoWriter::fourcc('V', 'P', '9', '0'), src.fps(), cv::Size(WIDTH, HEIGHT));
v2d->setSink(sink);
while (keep_running())
while (keepRunning())
iteration();
#else
Source src = make_capture_source(WIDTH, HEIGHT);

@ -46,7 +46,7 @@ using std::string;
using std::vector;
using std::istringstream;
cv::Ptr<cv::viz::Viz2D> v2d = new cv::viz::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Font Demo");
cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Font Demo");
vector<string> lines;
bool update_stars = true;
bool update_perspective = true;
@ -225,7 +225,7 @@ int main(int argc, char **argv) {
#ifndef __EMSCRIPTEN__
Sink sink = make_writer_sink(OUTPUT_FILENAME, cv::VideoWriter::fourcc('V', 'P', '9', '0'), FPS, cv::Size(WIDTH, HEIGHT));
v2d->setSink(sink);
while(keep_running())
while(keepRunning())
iteration();
#else
emscripten_set_main_loop(iteration, -1, true);

@ -124,7 +124,7 @@ int main(int argc, char **argv) {
exit(1);
}
cv::Ptr<Viz2D> v2d = new Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "NanoVG Demo");
cv::Ptr<Viz2D> v2d = Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "NanoVG Demo");
print_system_info();
if (!v2d->isOffscreen())
v2d->setVisible(true);

@ -47,9 +47,9 @@ const unsigned long DIAG = hypot(double(WIDTH), double(HEIGHT));
constexpr const char* OUTPUT_FILENAME = "optflow-demo.mkv";
constexpr bool OFFSCREEN = false;
static cv::Ptr<cv::viz::Viz2D> v2d = new cv::viz::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Sparse Optical Flow Demo");
static cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Sparse Optical Flow Demo");
#ifndef __EMSCRIPTEN__
static cv::Ptr<cv::viz::Viz2D> v2dMenu = new cv::viz::Viz2D(cv::Size(240, 360), cv::Size(240,360), false, "Display Settings");
static cv::Ptr<cv::viz::Viz2D> v2dMenu = cv::viz::Viz2D::make(cv::Size(240, 360), cv::Size(240,360), false, "Display Settings");
#endif
/** Visualization parameters **/
@ -491,7 +491,7 @@ int main(int argc, char **argv) {
Sink sink = make_writer_sink(OUTPUT_FILENAME, cv::VideoWriter::fourcc('V', 'P', '9', '0'), src.fps(), cv::Size(WIDTH, HEIGHT));
v2d->setSink(sink);
while (keep_running())
while (keepRunning())
iteration();
#else
Source src = make_capture_source(WIDTH, HEIGHT);

@ -115,7 +115,7 @@ int main(int argc, char **argv) {
exit(1);
}
cv::Ptr<Viz2D> v2d = new Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Beauty Demo");
cv::Ptr<Viz2D> v2d = Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Beauty Demo");
print_system_info();
if (!v2d->isOffscreen())
v2d->setVisible(true);
@ -145,7 +145,7 @@ int main(int argc, char **argv) {
cv::Rect lastTracked(0,0,1,1);
bool redetect = true;
while (keep_running()) {
while (keepRunning()) {
if(!v2d->capture())
break;

@ -322,7 +322,7 @@ void glow_effect(const cv::UMat &src, cv::UMat &dst, const int ksize) {
cv::bitwise_not(dst, dst);
}
cv::Ptr<cv::viz::Viz2D> v2d = new cv::viz::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Shader Demo");
cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Shader Demo");
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d) {
v2d->nanogui([](cv::viz::FormHelper& form){
@ -437,7 +437,7 @@ int main(int argc, char **argv) {
Sink sink = make_writer_sink(OUTPUT_FILENAME, cv::VideoWriter::fourcc('V', 'P', '9', '0'), FPS, cv::Size(WIDTH, HEIGHT));
v2d->setSink(sink);
while(keep_running())
while(keepRunning())
iteration();
#else
Source src = make_capture_source(WIDTH, HEIGHT);

@ -89,7 +89,7 @@ void glow_effect(const cv::UMat &src, cv::UMat &dst, const int ksize) {
int main(int argc, char **argv) {
using namespace cv::viz;
cv::Ptr<Viz2D> v2d = new Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Tetra Demo");
cv::Ptr<Viz2D> v2d = Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Tetra Demo");
print_system_info();
if(!v2d->isOffscreen())
v2d->setVisible(true);
@ -99,7 +99,7 @@ int main(int argc, char **argv) {
v2d->gl(init_scene);
while (keep_running()) {
while (keepRunning()) {
//Render using OpenGL
v2d->gl(render_scene);

@ -93,7 +93,7 @@ int main(int argc, char **argv) {
cerr << "Usage: video-demo <video-file>" << endl;
exit(1);
}
cv::Ptr<Viz2D> v2d = new Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Video Demo");
cv::Ptr<Viz2D> v2d = Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Video Demo");
print_system_info();
if(!v2d->isOffscreen())
v2d->setVisible(true);
@ -106,7 +106,7 @@ int main(int argc, char **argv) {
v2d->gl(init_scene);
while (keep_running()) {
while (keepRunning()) {
if(!v2d->capture())
break;

@ -125,7 +125,7 @@ static void install_signal_handlers() {
signal(SIGTERM, request_finish);
}
bool keep_running() {
bool keepRunning() {
if (!signal_handlers_installed) {
install_signal_handlers();
}

@ -47,6 +47,11 @@ cv::Scalar colorConvert(const cv::Scalar& src, cv::ColorConversionCodes code) {
return dst;
}
cv::Ptr<Viz2D> Viz2D::make(const cv::Size& initialSize, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major, int minor, int samples, bool debug) {
return new Viz2D(initialSize, frameBufferSize, offscreen, title, major, minor, samples, debug);
}
Viz2D::Viz2D(const cv::Size& size, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major, int minor, int samples, bool debug) :
initialSize_(size), frameBufferSize_(frameBufferSize), viewport_(0, 0,

Loading…
Cancel
Save