global renaming of viz2d to v4d

pull/3471/head
kallaballa 2 years ago
parent 4f6e81d9b2
commit 10b88dc7fd
  1. 15
      .gitignore
  2. 4
      .gitmodules
  3. 14
      README.md
  4. 14
      modules/v4d/CMakeLists.txt
  5. 0
      modules/v4d/doc/custom_source_and_sink.png
  6. 0
      modules/v4d/doc/display_image.png
  7. 0
      modules/v4d/doc/display_image_fb.png
  8. 0
      modules/v4d/doc/font_rendering.png
  9. 0
      modules/v4d/doc/font_with_gui.png
  10. 0
      modules/v4d/doc/render_opengl.png
  11. 0
      modules/v4d/doc/v4d.bib
  12. 0
      modules/v4d/doc/vector_graphics.png
  13. 0
      modules/v4d/doc/vector_graphics_and_fb.png
  14. 0
      modules/v4d/doc/video_editing.png
  15. 0
      modules/v4d/include/opencv2/v4d/cxxpool.hpp
  16. 14
      modules/v4d/include/opencv2/v4d/dialog.hpp
  17. 6
      modules/v4d/include/opencv2/v4d/formhelper.hpp
  18. 10
      modules/v4d/include/opencv2/v4d/nvg.hpp
  19. 10
      modules/v4d/include/opencv2/v4d/sink.hpp
  20. 12
      modules/v4d/include/opencv2/v4d/source.hpp
  21. 26
      modules/v4d/include/opencv2/v4d/util.hpp
  22. 38
      modules/v4d/include/opencv2/v4d/v4d.hpp
  23. 2
      modules/v4d/samples/cpp/Makefile
  24. 0
      modules/v4d/samples/cpp/assets
  25. 2
      modules/v4d/samples/cpp/beauty/Makefile
  26. 0
      modules/v4d/samples/cpp/beauty/assets
  27. 8
      modules/v4d/samples/cpp/beauty/beauty-demo.cpp
  28. 2
      modules/v4d/samples/cpp/beauty/beauty.html
  29. 0
      modules/v4d/samples/cpp/beauty/get.php
  30. 0
      modules/v4d/samples/cpp/beauty/index.php
  31. 6
      modules/v4d/samples/cpp/custom_source_and_sink.cpp
  32. 8
      modules/v4d/samples/cpp/display_image.cpp
  33. 6
      modules/v4d/samples/cpp/display_image_fb.cpp
  34. 2
      modules/v4d/samples/cpp/font/Makefile
  35. 8
      modules/v4d/samples/cpp/font/font-demo.cpp
  36. 0
      modules/v4d/samples/cpp/font/font.html
  37. 0
      modules/v4d/samples/cpp/font/get.php
  38. 0
      modules/v4d/samples/cpp/font/index.php
  39. 6
      modules/v4d/samples/cpp/font_rendering.cpp
  40. 6
      modules/v4d/samples/cpp/font_with_gui.cpp
  41. 2
      modules/v4d/samples/cpp/nanovg/Makefile
  42. 6
      modules/v4d/samples/cpp/nanovg/nanovg-demo.cpp
  43. 2
      modules/v4d/samples/cpp/optflow/Makefile
  44. 0
      modules/v4d/samples/cpp/optflow/get.php
  45. 0
      modules/v4d/samples/cpp/optflow/index.php
  46. 2
      modules/v4d/samples/cpp/optflow/local.html
  47. 10
      modules/v4d/samples/cpp/optflow/optflow-demo.cpp
  48. 2
      modules/v4d/samples/cpp/optflow/optflow.html
  49. 2
      modules/v4d/samples/cpp/pedestrian/Makefile
  50. 8
      modules/v4d/samples/cpp/pedestrian/pedestrian-demo.cpp
  51. 4
      modules/v4d/samples/cpp/render_opengl.cpp
  52. 2
      modules/v4d/samples/cpp/shader/Makefile
  53. 0
      modules/v4d/samples/cpp/shader/get.php
  54. 0
      modules/v4d/samples/cpp/shader/index.php
  55. 18
      modules/v4d/samples/cpp/shader/shader-demo.cpp
  56. 0
      modules/v4d/samples/cpp/shader/shader.html
  57. 2
      modules/v4d/samples/cpp/tetra/Makefile
  58. 8
      modules/v4d/samples/cpp/tetra/tetra-demo.cpp
  59. 6
      modules/v4d/samples/cpp/vector_graphics.cpp
  60. 6
      modules/v4d/samples/cpp/vector_graphics_and_fb.cpp
  61. 2
      modules/v4d/samples/cpp/video/Makefile
  62. 8
      modules/v4d/samples/cpp/video/video-demo.cpp
  63. 6
      modules/v4d/samples/cpp/video_editing.cpp
  64. 2
      modules/v4d/src/detail/clvacontext.cpp
  65. 4
      modules/v4d/src/detail/clvacontext.hpp
  66. 8
      modules/v4d/src/detail/framebuffercontext.cpp
  67. 10
      modules/v4d/src/detail/framebuffercontext.hpp
  68. 8
      modules/v4d/src/detail/nanovgcontext.cpp
  69. 14
      modules/v4d/src/detail/nanovgcontext.hpp
  70. 12
      modules/v4d/src/dialog.cpp
  71. 2
      modules/v4d/src/formhelper.cpp
  72. 2
      modules/v4d/src/nvg.cpp
  73. 4
      modules/v4d/src/sink.cpp
  74. 4
      modules/v4d/src/source.cpp
  75. 12
      modules/v4d/src/util.cpp
  76. 150
      modules/v4d/src/v4d.cpp
  77. 0
      modules/v4d/third/nanogui
  78. 78
      modules/v4d/tutorials/00-intro.markdown
  79. 8
      modules/v4d/tutorials/01-dislay_image.markdown
  80. 6
      modules/v4d/tutorials/02-vector_graphics.markdown
  81. 6
      modules/v4d/tutorials/03-render_opengl.markdown
  82. 6
      modules/v4d/tutorials/04-font_rendering.markdown
  83. 6
      modules/v4d/tutorials/05-video_editing.markdown
  84. 17
      modules/v4d/tutorials/06-custom_source_and_sink.markdown
  85. 4
      modules/v4d/tutorials/07-font_with_gui.markdown
  86. 6
      modules/v4d/tutorials/10-tetra.markdown
  87. 6
      modules/v4d/tutorials/11-video.markdown
  88. 6
      modules/v4d/tutorials/12-nanovg.markdown
  89. 6
      modules/v4d/tutorials/13-shader.markdown
  90. 6
      modules/v4d/tutorials/14-font.markdown
  91. 6
      modules/v4d/tutorials/15-pedestrian.markdown
  92. 6
      modules/v4d/tutorials/16-optflow.markdown
  93. 4
      modules/v4d/tutorials/17-beauty.markdown
  94. 17
      modules/viz2d/tutorials/06-custom_source_and_sink.markdown

15
.gitignore vendored

@ -11,21 +11,6 @@ src/*/*.wasm
src/*/*/*.o
src/*/*/*.dep
src/*/*/*.d
src/common/libviz2d.so
src/tetra/tetra-demo
src/video/video-demo
src/shader/shader-demo
src/nanovg/nanovg-demo
src/optflow/optflow-demo
src/beauty/beauty-demo
src/font/font-demo
src/pedestrian/pedestrian-demo
*.webm
*.mkv
apidoc/
docbook/
latex/
src/beauty/assets
src/beauty/beauty-demo.data
src/quad/quad-demo

4
.gitmodules vendored

@ -1,3 +1,3 @@
[submodule "modules/viz2d/third/nanogui"]
path = modules/viz2d/third/nanogui
[submodule "modules/v4d/third/nanogui"]
path = modules/v4d/third/nanogui
url = https://github.com/kallaballa/nanogui.git

@ -1,11 +1,11 @@
# Viz2D
Viz2D is a visualization module for [OpenCV](https://github.com/opencv/opencv). It features vector graphics using [NanoVG](https://github.com/memononen/nanovg) a GUI based on [NanoGUI](https://github.com/mitsuba-renderer/nanogui) and (on supported systems) OpenCL/OpenGL and OpenCL/VAAPI interoperability. It should be included in [OpenCV-contrib](https://github.com/opencv/opencv_contrib) once it is ready.
# V4D
V4D is a visualization module for [OpenCV](https://github.com/opencv/opencv). It features vector graphics using [NanoVG](https://github.com/memononen/nanovg) a GUI based on [NanoGUI](https://github.com/mitsuba-renderer/nanogui) and (on supported systems) OpenCL/OpenGL and OpenCL/VAAPI interoperability. It should be included in [OpenCV-contrib](https://github.com/opencv/opencv_contrib) once it is ready.
# What is Viz2D?
Viz2D is a way of writing graphical (on- and offscreen) high performance applications with OpenCV. It is light-weight and unencumbered by QT or GTK licenses.
# What is V4D?
V4D is a way of writing graphical (on- and offscreen) high performance applications with OpenCV. It is light-weight and unencumbered by QT or GTK licenses.
# Why Viz2D?
Please refer to the [online demos](https://github.com/kallaballa/Viz2D/blob/main/README.md#online-demos) to see at a glance what it can do for you.
# Why V4D?
Please refer to the [online demos](https://github.com/kallaballa/V4D/blob/main/README.md#online-demos) to see at a glance what it can do for you.
* OpenGL: Easy access to OpenGL.
* GUI: Simple yet powerful user interfaces through NanoGUI.
@ -25,7 +25,7 @@ Please note that the following online demos are slower and/or have less features
* https://viel-zu.org/opencv/beauty
# Documentation
OpenCV module documentation with tutorials, samples and build instructions is available [here](https://viel-zu.org/opencv/doxygen/html/dc/d7b/viz2d.html)
OpenCV module documentation with tutorials, samples and build instructions is available [here](https://viel-zu.org/opencv/doxygen/html/dc/d7b/v4d.html)
# Attribution
* The author of the bunny video is **(c) copyright Blender Foundation | www.bigbuckbunny.org**.

@ -1,16 +1,16 @@
include("FindGLEW")
set(the_description "Viz2D Visualization Module")
set(the_description "V4D Visualization Module")
if(NOT GLEW_FOUND)
message(STATUS "Module opencv_viz2d disabled because GLEW was not found")
ocv_module_disable(viz2d)
message(STATUS "Module opencv_v4d disabled because GLEW was not found")
ocv_module_disable(v4d)
endif()
get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
list (FIND known_features "cxx_std_20" idx)
if (${idx} LESS 0)
message(STATUS "Module opencv_viz2d disabled because it requires C++20")
ocv_module_disable(viz2d)
message(STATUS "Module opencv_v4d disabled because it requires C++20")
ocv_module_disable(v4d)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_LD_FLAGS} -L../../lib")
@ -35,7 +35,7 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third/nanogui/ext/nanovg/src/")
include_directories(${GLEW_INCLUDE_DIRS})
link_directories(${GLEW_LIBRARY_DIRS})
ocv_add_module(viz2d opencv_core opencv_imgproc opencv_videoio opencv_video)
ocv_add_module(v4d opencv_core opencv_imgproc opencv_videoio opencv_video)
ocv_glob_module_sources()
ocv_module_include_directories()
ocv_create_module()
@ -46,7 +46,7 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third/nanogui)
add_library(nanovg "third/nanogui/ext/nanovg/src/nanovg.c")
target_compile_features(opencv_viz2d PRIVATE cxx_std_20)
target_compile_features(opencv_v4d PRIVATE cxx_std_20)
#ocv_add_samples(opencv_aruco)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-parameter -Wdeprecated-enum-enum-conversion)

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Before

Width:  |  Height:  |  Size: 685 KiB

After

Width:  |  Height:  |  Size: 685 KiB

Before

Width:  |  Height:  |  Size: 993 KiB

After

Width:  |  Height:  |  Size: 993 KiB

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 993 KiB

After

Width:  |  Height:  |  Size: 993 KiB

@ -3,13 +3,13 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#ifndef SRC_OPENCV_VIZ2D_DIALOG_HPP_
#define SRC_OPENCV_VIZ2D_DIALOG_HPP_
#ifndef SRC_OPENCV_V4D_DIALOG_HPP_
#define SRC_OPENCV_V4D_DIALOG_HPP_
#ifdef __EMSCRIPTEN__
#define VIZ2D_USE_ES3 1
#define V4D_USE_ES3 1
#endif
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
#define NANOGUI_USE_OPENGL
#else
#define NANOGUI_USE_GLES
@ -33,8 +33,8 @@ using std::string;
*/
class CV_EXPORTS Dialog: public nanogui::Window {
private:
static std::function<bool(Dialog*, Dialog*)> viz2DWin_Xcomparator;
static std::set<Dialog*, decltype(viz2DWin_Xcomparator)> all_windows_xsorted_;
static std::function<bool(Dialog*, Dialog*)> v4dWin_Xcomparator;
static std::set<Dialog*, decltype(v4dWin_Xcomparator)> all_windows_xsorted_;
nanogui::Screen* screen_;
nanogui::Vector2i lastDragPos_;
nanogui::Vector2i maximizedPos_;
@ -68,4 +68,4 @@ public:
} /* namespace viz */
} /* namespace cv */
#endif /* SRC_OPENCV_VIZ2D_DIALOG_HPP_ */
#endif /* SRC_OPENCV_V4D_DIALOG_HPP_ */

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#ifndef SRC_OPENCV_VIZ2D_FORMHELPER_HPP_
#define SRC_OPENCV_VIZ2D_FORMHELPER_HPP_
#ifndef SRC_OPENCV_V4D_FORMHELPER_HPP_
#define SRC_OPENCV_V4D_FORMHELPER_HPP_
#include "dialog.hpp"
#include <nanogui/screen.h>
@ -126,4 +126,4 @@ public:
} /* namespace viz */
} /* namespace cv */
#endif /* SRC_OPENCV_VIZ2D_FORMHELPER_HPP_ */
#endif /* SRC_OPENCV_V4D_FORMHELPER_HPP_ */

@ -3,10 +3,10 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#ifndef SRC_OPENCV_VIZ2D_NVG_HPP_
#define SRC_OPENCV_VIZ2D_NVG_HPP_
#ifndef SRC_OPENCV_V4D_NVG_HPP_
#define SRC_OPENCV_V4D_NVG_HPP_
#include "viz2d.hpp"
#include "v4d.hpp"
#ifndef __EMSCRIPTEN__
#define NANOGUI_USE_OPENGL
#else
@ -84,7 +84,7 @@ namespace detail {
*/
class NVG {
private:
friend class Viz2D;
friend class V4D;
static NVG* nvg_instance_;
NVGcontext* ctx_ = nullptr;
NVG(NVGcontext* ctx) :
@ -517,4 +517,4 @@ CV_EXPORTS void resetScissor();
}
}
#endif /* SRC_OPENCV_VIZ2D_NVG_HPP_ */
#endif /* SRC_OPENCV_V4D_NVG_HPP_ */

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#ifndef SRC_OPENCV_VIZ2D_SINK_HPP_
#define SRC_OPENCV_VIZ2D_SINK_HPP_
#ifndef SRC_OPENCV_V4D_SINK_HPP_
#define SRC_OPENCV_V4D_SINK_HPP_
#include <functional>
#include <opencv2/core/cvdef.h>
@ -14,7 +14,7 @@ namespace cv {
namespace viz {
/*!
* A Sink object represents a way to write data produced by Viz2D (e.g. a video-file).
* A Sink object represents a way to write data produced by V4D (e.g. a video-file).
*/
class CV_EXPORTS Sink {
bool open_ = true;
@ -50,7 +50,7 @@ public:
CV_EXPORTS void operator()(const cv::UMat& frame);
};
} /* namespace viz2d */
} /* namespace v4d */
} /* namespace kb */
#endif /* SRC_OPENCV_VIZ2D_SINK_HPP_ */
#endif /* SRC_OPENCV_V4D_SINK_HPP_ */

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#ifndef SRC_OPENCV_VIZ2D_SOURCE_HPP_
#define SRC_OPENCV_VIZ2D_SOURCE_HPP_
#ifndef SRC_OPENCV_V4D_SOURCE_HPP_
#define SRC_OPENCV_V4D_SOURCE_HPP_
#include <functional>
#include <opencv2/core/cvdef.h>
@ -14,7 +14,7 @@ namespace cv {
namespace viz {
/*!
* A Source object represents a way to provide data to Viz2D by using
* A Source object represents a way to provide data to V4D by using
* a generator functor.
*/
class CV_EXPORTS Source {
@ -27,7 +27,7 @@ public:
/*!
* Constructs the Source object from a generator functor.
* @param generator A function object that accepts a reference to a UMat frame
* that it manipulates. This is ultimatively used to provide video data to #cv::viz::Viz2D
* that it manipulates. This is ultimatively used to provide video data to #cv::viz::V4D
* @param fps The fps the Source object provides data with.
*/
CV_EXPORTS Source(std::function<bool(cv::UMat&)> generator, float fps);
@ -62,7 +62,7 @@ public:
CV_EXPORTS std::pair<uint64_t, cv::UMat&> operator()();
};
} /* namespace viz2d */
} /* namespace v4d */
} /* namespace kb */
#endif /* SRC_OPENCV_VIZ2D_SOURCE_HPP_ */
#endif /* SRC_OPENCV_V4D_SOURCE_HPP_ */

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#ifndef SRC_OPENCV_VIZ2D_UTIL_HPP_
#define SRC_OPENCV_VIZ2D_UTIL_HPP_
#ifndef SRC_OPENCV_V4D_UTIL_HPP_
#define SRC_OPENCV_V4D_UTIL_HPP_
#include "source.hpp"
#include "sink.hpp"
@ -22,7 +22,7 @@
namespace cv {
namespace viz {
using std::string;
class Viz2D;
class V4D;
/*!
* Returns the OpenGL Version information.
* @return a string object with the OpenGL version information
@ -56,14 +56,14 @@ CV_EXPORTS bool keepRunning();
/*!
* Little helper function to keep track of FPS and optionally display it using NanoVG
* @param v2d The Viz2D object to operate on
* @param v2d The V4D object to operate on
* @param graphical if this parameter is true the FPS drawn on display
*/
CV_EXPORTS void updateFps(cv::Ptr<Viz2D> v2d, bool graphical);
CV_EXPORTS void updateFps(cv::Ptr<V4D> v2d, bool graphical);
#ifndef __EMSCRIPTEN__
/*!
* Creates an Intel VAAPI enabled VideoWriter sink object to use in conjunction with #Viz2D::setSink().
* Creates an Intel VAAPI enabled VideoWriter sink object to use in conjunction with #V4D::setSink().
* Usually you would call #makeWriterSink() and let it automatically decide if VAAPI is available.
* @param outputFilename The filename to write the video to.
* @param fourcc The fourcc code of the codec to use.
@ -75,7 +75,7 @@ CV_EXPORTS void updateFps(cv::Ptr<Viz2D> v2d, bool graphical);
CV_EXPORTS Sink makeVaSink(const string& outputFilename, const int fourcc, const float fps,
const cv::Size& frameSize, const int vaDeviceIndex);
/*!
* Creates an Intel VAAPI enabled VideoCapture source object to use in conjunction with #Viz2D::setSource().
* Creates an Intel VAAPI enabled VideoCapture source object to use in conjunction with #V4D::setSource().
* Usually you would call #makeCaptureSource() and let it automatically decide if VAAPI is available.
* @param inputFilename The file to read from.
* @param vaDeviceIndex The VAAPI device index to use.
@ -83,7 +83,7 @@ CV_EXPORTS Sink makeVaSink(const string& outputFilename, const int fourcc, const
*/
CV_EXPORTS Source makeVaSource(const string& inputFilename, const int vaDeviceIndex);
/*!
* Creates a VideoWriter sink object to use in conjunction with #Viz2D::setSink().
* Creates a VideoWriter sink object to use in conjunction with #V4D::setSink().
* This function automatically determines if Intel VAAPI is available and enables it if so.
* @param outputFilename The filename to write the video to.
* @param fourcc The fourcc code of the codec to use.
@ -94,7 +94,7 @@ CV_EXPORTS Source makeVaSource(const string& inputFilename, const int vaDeviceIn
CV_EXPORTS Sink makeWriterSink(const string& outputFilename, const int fourcc, const float fps,
const cv::Size& frameSize);
/*!
* Creates a VideoCapture source object to use in conjunction with #Viz2D::setSource().
* Creates a VideoCapture source object to use in conjunction with #V4D::setSource().
* This function automatically determines if Intel VAAPI is available and enables it if so.
* @param inputFilename The file to read from.
* @return A (optionally VAAPI enabled) VideoCapture enabled source object.
@ -102,10 +102,10 @@ CV_EXPORTS Sink makeWriterSink(const string& outputFilename, const int fourcc, c
CV_EXPORTS Source makeCaptureSource(const string& inputFilename);
#else
/*!
* Creates a WebCam source object to use in conjunction with #Viz2D::setSource().
* Creates a WebCam source object to use in conjunction with #V4D::setSource().
* In the background it uses emscripten's file system implementation to transfer frames from the camera to the source object
* @param width The frame width to capture (usually the initial width of the Viz2D object)
* @param height The frame height to capture (usually the initial height of the Viz2D object)
* @param width The frame width to capture (usually the initial width of the V4D object)
* @param height The frame height to capture (usually the initial height of the V4D object)
* @return A WebCam source object.
*/
CV_EXPORTS Source makeCaptureSource(int width, int height);
@ -114,4 +114,4 @@ CV_EXPORTS Source makeCaptureSource(int width, int height);
}
}
#endif /* SRC_OPENCV_VIZ2D_UTIL_HPP_ */
#endif /* SRC_OPENCV_V4D_UTIL_HPP_ */

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#ifndef SRC_OPENCV_VIZ2D_VIZ2D_HPP_
#define SRC_OPENCV_VIZ2D_VIZ2D_HPP_
#ifndef SRC_OPENCV_V4D_V4D_HPP_
#define SRC_OPENCV_V4D_V4D_HPP_
#include "source.hpp"
#include "sink.hpp"
@ -21,18 +21,18 @@
#include "cxxpool.hpp"
#ifdef __EMSCRIPTEN__
#define VIZ2D_USE_ES3 1
#define V4D_USE_ES3 1
#include <emscripten.h>
#endif
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
#define NANOGUI_USE_OPENGL
#else
#define NANOGUI_USE_GLES
#define NANOGUI_GLES_VERSION 3
#endif
#include <nanogui/nanogui.h>
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
#include <GL/glew.h>
#else
#include <GLES3/gl3.h>
@ -118,7 +118,7 @@ using namespace cv::viz::detail;
class NVG;
class CV_EXPORTS Viz2D {
class CV_EXPORTS V4D {
friend class NanoVGContext;
const cv::Size initialSize_;
cv::Size frameBufferSize_;
@ -160,16 +160,16 @@ class CV_EXPORTS Viz2D {
std::function<bool(int key, int scancode, int action, int modifiers)> keyEventCb_;
public:
/*!
* Creates a Viz2D object which is the central object to perform visualizations with.
* Creates a V4D object which is the central object to perform visualizations with.
* @param size The window and framebuffer size
* @param title The window title.
* @param debug Create a debug OpenGL context.
*/
CV_EXPORTS static cv::Ptr<Viz2D> make(const cv::Size& size, const string& title, bool debug =
CV_EXPORTS static cv::Ptr<V4D> make(const cv::Size& size, const string& title, bool debug =
false);
/*!
* Creates a Viz2D object which is the central object to perform visualizations with.
* Creates a V4D 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.
@ -179,21 +179,21 @@ public:
* @param samples MSAA samples.
* @param debug Create a debug OpenGL context.
*/
CV_EXPORTS static cv::Ptr<Viz2D> make(const cv::Size& initialSize,
CV_EXPORTS static cv::Ptr<V4D> make(const cv::Size& initialSize,
const cv::Size& frameBufferSize, bool offscreen, const string& title, int major = 3,
int minor = 2, bool compat = true, int samples = 0, bool debug = false);
/*!
* Default destructor
*/
CV_EXPORTS virtual ~Viz2D();
CV_EXPORTS virtual ~V4D();
/*!
* In case several Viz2D objects are in use all objects not in use have to
* In case several V4D objects are in use all objects not in use have to
* call #makeNoneCurrent() and only the one to be active call #makeCurrent().
*/
CV_EXPORTS void makeCurrent();
/*!
* To make it possible for other Viz2D objects to become current all other
* Viz2d instances have to become non-current.
* To make it possible for other V4D objects to become current all other
* V4D instances have to become non-current.
*/
CV_EXPORTS void makeNoneCurrent();
@ -250,7 +250,7 @@ public:
*/
CV_EXPORTS void feed(cv::InputArray& in);
/*!
* Called to capture to the framebuffer from a #cv::viz::Source object provided via #Viz2D::setSource().
* Called to capture to the framebuffer from a #cv::viz::Source object provided via #V4D::setSource().
* @return true if successful.
*/
CV_EXPORTS bool capture();
@ -263,7 +263,7 @@ public:
*/
CV_EXPORTS bool capture(std::function<void(cv::UMat&)> fn);
/*!
* Called to write the framebuffer to a #cv::viz::Sink object provided via #Viz2D::setSink()
* Called to write the framebuffer to a #cv::viz::Sink object provided via #V4D::setSink()
*/
CV_EXPORTS void write();
/*!
@ -429,7 +429,7 @@ public:
CV_EXPORTS bool display();
private:
/*!
* Creates a Viz2D object which is the central object to perform visualizations with.
* Creates a V4D 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.
@ -439,7 +439,7 @@ private:
* @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 V4D(const cv::Size& initialSize, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major = 3, int minor = 2, bool compat = true, int samples = 0, bool debug = false);
void setDefaultKeyboardEventCallback();
void setKeyboardEventCallback(
@ -461,4 +461,4 @@ private:
}
} /* namespace kb */
#endif /* SRC_OPENCV_VIZ2D_VIZ2D_HPP_ */
#endif /* SRC_OPENCV_V4D_V4D_HPP_ */

@ -4,7 +4,7 @@ ifdef EMSDK
LDFLAGS := -flto -L/usr/local/lib/ -L../common
LIBS := -lopencv_core -lopencv_imgproc -lnanogui
else
#CXXFLAGS += -DVIZ2D_USE_ES3=1
#CXXFLAGS += -DV4D_USE_ES3=1
LDFLAGS := -L/opt/local/lib -flto -L/usr/local/lib64 -L../common/ -L/usr/local/lib
LIBS := -lnanogui
endif

@ -15,7 +15,7 @@ CXXFLAGS += -fpic
ifdef EMSDK
LDFLAGS += --preload-file assets/
endif
LIBS += -lm -lopencv_dnn -lopencv_face -lopencv_objdetect -lopencv_stitching -lopencv_viz2d
LIBS += -lm -lopencv_dnn -lopencv_face -lopencv_objdetect -lopencv_stitching -lopencv_v4d
ifndef EMSDK
LIBS += -lOpenCL
else

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/viz2d/nvg.hpp"
#include "opencv2/v4d/v4d.hpp"
#include "opencv2/v4d/nvg.hpp"
#include <vector>
#include <string>
@ -47,7 +47,7 @@ bool side_by_side = false;
bool stretch = false;
#endif
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::viz::V4D> v2d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Beauty Demo");
static cv::Ptr<cv::face::Facemark> facemark = cv::face::createFacemarkLBF(); //Face landmark detection
#ifdef USE_TRACKER
static cv::Ptr<cv::Tracker> tracker = cv::TrackerKCF::create(); //Instead of continues face detection we can use a tracker
@ -192,7 +192,7 @@ void adjust_saturation(const cv::UMat &srcBGR, cv::UMat &dstBGR, float factor) {
}
//Setup the gui
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d) {
void setup_gui(cv::Ptr<cv::viz::V4D> v2d) {
v2d->nanogui([&](cv::viz::FormHelper& form){
form.makeDialog(5, 30, "Effect");

@ -215,7 +215,7 @@
let ctx = cameraCanvas.getContext('2d', { willReadFrequently: true });
ctx.drawImage(videoElement, 0, 0, cameraCanvas.width, cameraCanvas.height);
var imageData = ctx.getImageData(0, 0, cameraCanvas.width, cameraCanvas.height);
let filename = 'viz2d_rgba_canvas.raw';
let filename = 'v4d_rgba_canvas.raw';
let stream = FS.open(filename, 'w+');
if(imageData) {
FS.write(stream, imageData.data, 0, imageData.data.length, 0);

@ -1,5 +1,5 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/viz2d/nvg.hpp>
#include <opencv2/v4d/v4d.hpp>
#include <opencv2/v4d/nvg.hpp>
#include <opencv2/imgcodecs.hpp>
using namespace cv;
@ -10,7 +10,7 @@ constexpr int HEIGHT = 720;
int main(int argc, char** argv) {
string hr = "Hello Rainbow!";
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "Video Editing");
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "Video Editing");
//Make a Source that generates rainbow frames.
Source src([=](cv::UMat& frame){
static long cnt = 0;

@ -1,4 +1,4 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/v4d/v4d.hpp>
using namespace cv;
using namespace cv::viz;
@ -7,15 +7,15 @@ constexpr int WIDTH = 1280;
constexpr int HEIGHT = 720;
int main() {
//Creates a Viz2D object for on screen rendering
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "Show image");
//Creates a V4D object for on screen rendering
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "Show image");
//An image
Mat image = imread(samples::findFile("lena.jpg"));
//Feeds the image to the video pipeline
v2d->feed(image);
//Display the framebuffer in the native window in an endless loop.
//Viz2D::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
//terminates or the functor returns false.
v2d->run(v2d->display);

@ -1,4 +1,4 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/v4d/v4d.hpp>
using namespace cv;
using namespace cv::viz;
@ -7,8 +7,8 @@ constexpr int WIDTH = 1280;
constexpr int HEIGHT = 720;
int main() {
//Creates a Viz2D object for on screen rendering
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "Show image");
//Creates a V4D object for on screen rendering
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "Show image");
//Read an image as UMat
UMat image = imread(samples::findFile("lena.jpg")).getUMat(ACCESS_READ);
UMat resized;

@ -12,7 +12,7 @@ DEPS := ${SRCS:.cpp=.dep}
CXXFLAGS += -fpic
LDFLAGS +=
LIBS += -lm -lopencv_viz2d
LIBS += -lm -lopencv_v4d
.PHONY: all release debug clean distclean

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/viz2d/nvg.hpp"
#include "opencv2/v4d/v4d.hpp"
#include "opencv2/v4d/nvg.hpp"
#include <string>
#include <algorithm>
@ -45,12 +45,12 @@ using std::string;
using std::vector;
using std::istringstream;
cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Font Demo");
cv::Ptr<cv::viz::V4D> v2d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Font Demo");
vector<string> lines;
bool update_stars = true;
bool update_perspective = true;
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d) {
void setup_gui(cv::Ptr<cv::viz::V4D> v2d) {
v2d->nanogui([&](cv::viz::FormHelper& form){
form.makeDialog(5, 30, "Effect");
form.makeGroup("Text Crawl");

@ -1,5 +1,5 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/viz2d/nvg.hpp>
#include <opencv2/v4d/v4d.hpp>
#include <opencv2/v4d/nvg.hpp>
using namespace cv;
using namespace cv::viz;
@ -8,7 +8,7 @@ constexpr int WIDTH = 1280;
constexpr int HEIGHT = 720;
int main(int argc, char** argv) {
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "Font Rendering");
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "Font Rendering");
//The text to render
string hw = "Hello World";

@ -1,5 +1,5 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/viz2d/nvg.hpp>
#include <opencv2/v4d/v4d.hpp>
#include <opencv2/v4d/nvg.hpp>
using namespace cv;
using namespace cv::viz;
@ -8,7 +8,7 @@ constexpr int WIDTH = 1280;
constexpr int HEIGHT = 720;
int main(int argc, char** argv) {
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "Font Rendering with GUI");
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "Font Rendering with GUI");
//The text color. NanoGUI uses rgba with floating point
nanogui::Color textColor = {0.0f, 0.0f, 1.0f, 1.0f};
//The font size

@ -9,7 +9,7 @@ DEPS := ${SRCS:.cpp=.dep}
CXXFLAGS += -fpic
LDFLAGS +=
LIBS += -lm -lopencv_viz2d
LIBS += -lm -lopencv_v4d
.PHONY: all release debug clean distclean
all: release

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/viz2d/nvg.hpp"
#include "opencv2/v4d/v4d.hpp"
#include "opencv2/v4d/nvg.hpp"
constexpr unsigned int WIDTH = 1920;
constexpr unsigned int HEIGHT = 1080;
@ -14,7 +14,7 @@ constexpr const char *OUTPUT_FILENAME = "nanovg-demo.mkv";
using std::cerr;
using std::endl;
static cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "NanoVG Demo");
static cv::Ptr<cv::viz::V4D> v2d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "NanoVG Demo");
void draw_color_wheel(float x, float y, float w, float h, float hue) {
//color wheel drawing code taken from https://github.com/memononen/nanovg/blob/master/example/demo.c

@ -12,7 +12,7 @@ OBJS := ${SRCS:.cpp=.o}
DEPS := ${SRCS:.cpp=.dep}
CXXFLAGS += -fpic
LIBS += -lm -lopencv_optflow -lopencv_video -lopencv_features2d -lopencv_viz2d -lz
LIBS += -lm -lopencv_optflow -lopencv_video -lopencv_features2d -lopencv_v4d -lz
ifndef EMSDK
LIBS += -lOpenCL
endif

@ -214,7 +214,7 @@
let ctx = cameraCanvas.getContext('2d', { willReadFrequently: true });
ctx.drawImage(videoElement, 0, 0, cameraCanvas.width, cameraCanvas.height);
var imageData = ctx.getImageData(0, 0, cameraCanvas.width, cameraCanvas.height);
let filename = 'viz2d_rgba_canvas.raw';
let filename = 'v4d_rgba_canvas.raw';
let stream = FS.open(filename, 'w+');
if(imageData) {
FS.write(stream, imageData.data, 0, imageData.data.length, 0);

@ -3,8 +3,8 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/viz2d/nvg.hpp"
#include "opencv2/v4d/v4d.hpp"
#include "opencv2/v4d/nvg.hpp"
#include <cmath>
#include <vector>
@ -46,9 +46,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 = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Sparse Optical Flow Demo");
static cv::Ptr<cv::viz::V4D> v2d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Sparse Optical Flow Demo");
#ifndef __EMSCRIPTEN__
static cv::Ptr<cv::viz::Viz2D> v2dMenu = cv::viz::Viz2D::make(cv::Size(240, 360), cv::Size(240,360), false, "Display Settings");
static cv::Ptr<cv::viz::V4D> v2dMenu = cv::viz::V4D::make(cv::Size(240, 360), cv::Size(240,360), false, "Display Settings");
#endif
/** Visualization parameters **/
@ -305,7 +305,7 @@ void composite_layers(cv::UMat& background, const cv::UMat& foreground, const cv
cv::add(background, post, dst);
}
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d, cv::Ptr<cv::viz::Viz2D> v2dMenu) {
void setup_gui(cv::Ptr<cv::viz::V4D> v2d, cv::Ptr<cv::viz::V4D> v2dMenu) {
v2d->nanogui([&](cv::viz::FormHelper& form){
form.makeDialog(5, 30, "Effects");

@ -215,7 +215,7 @@
let ctx = cameraCanvas.getContext('2d', { willReadFrequently: true });
ctx.drawImage(videoElement, 0, 0, cameraCanvas.width, cameraCanvas.height);
var imageData = ctx.getImageData(0, 0, cameraCanvas.width, cameraCanvas.height);
let filename = 'viz2d_rgba_canvas.raw';
let filename = 'v4d_rgba_canvas.raw';
let stream = FS.open(filename, 'w+');
if(imageData) {
FS.write(stream, imageData.data, 0, imageData.data.length, 0);

@ -9,7 +9,7 @@ DEPS := ${SRCS:.cpp=.dep}
CXXFLAGS += -fpic
LDFLAGS +=
LIBS += -lm -lOpenCL -lopencv_viz2d
LIBS += -lm -lOpenCL -lopencv_v4d
.PHONY: all release debug clean distclean
all: release

@ -3,9 +3,9 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/viz2d/nvg.hpp"
#include "opencv2/viz2d/util.hpp"
#include "opencv2/v4d/v4d.hpp"
#include "opencv2/v4d/nvg.hpp"
#include "opencv2/v4d/util.hpp"
#include <string>
@ -30,7 +30,7 @@ using std::endl;
using std::vector;
using std::string;
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::viz::V4D> v2d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Beauty Demo");
static cv::HOGDescriptor hog;
//adapted from cv::dnn_objdetect::InferBbox

@ -1,4 +1,4 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/v4d/v4d.hpp>
using namespace cv;
using namespace cv::viz;
@ -7,7 +7,7 @@ constexpr int WIDTH = 1280;
constexpr int HEIGHT = 720;
int main(int argc, char** argv) {
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "GL Tetrahedron");
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "GL Tetrahedron");
v2d->gl([](const Size sz) {
//Initialize the OpenGL scene

@ -12,7 +12,7 @@ DEPS := ${SRCS:.cpp=.dep}
CXXFLAGS += -fpic
LDFLAGS +=
LIBS += -lm -lopencv_viz2d
LIBS += -lm -lopencv_v4d
.PHONY: all release debug clean distclean
all: release

@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/v4d/v4d.hpp"
using std::cerr;
using std::endl;
@ -44,7 +44,7 @@ GLint zoom_hdl;
/** shader and program handle **/
GLuint shader_program_hdl;
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
//vertex array
GLuint VAO;
#endif
@ -71,7 +71,7 @@ unsigned int indices[] =
void load_buffer_data(){
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
glGenVertexArrays(1, &VAO);
glBindVertexArray(VAO);
#endif
@ -89,7 +89,7 @@ void load_buffer_data(){
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
glBindVertexArray(0);
#endif
}
@ -141,7 +141,7 @@ GLuint init_shader(const char* vShader, const char* fShader, const char* outputA
glAttachShader( program, shader );
}
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
/* Link output */
glBindFragDataLocation(program, 0, outputAttributeName);
#endif
@ -170,7 +170,7 @@ GLuint init_shader(const char* vShader, const char* fShader, const char* outputA
//mandelbrot shader code adapted from my own project: https://github.com/kallaballa/FractalDive#after
void load_shader(){
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
const string shaderVersion = "330";
#else
const string shaderVersion = "300 es";
@ -293,7 +293,7 @@ void render_scene(const cv::Size& sz) {
glUniform1f(zoom_hdl, zoom);
}
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
glBindVertexArray(VAO);
#endif
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
@ -321,9 +321,9 @@ void glow_effect(const cv::UMat &src, cv::UMat &dst, const int ksize) {
cv::bitwise_not(dst, dst);
}
cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Shader Demo");
cv::Ptr<cv::viz::V4D> v2d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Shader Demo");
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d) {
void setup_gui(cv::Ptr<cv::viz::V4D> v2d) {
v2d->nanogui([](cv::viz::FormHelper& form){
form.makeDialog(5, 30, "Fractal");

@ -9,7 +9,7 @@ DEPS := ${SRCS:.cpp=.dep}
CXXFLAGS += -fpic
LDFLAGS +=
LIBS += -lm -lopencv_viz2d -lEGL
LIBS += -lm -lopencv_v4d -lEGL
.PHONY: all release debug clean distclean
all: release

@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/v4d/v4d.hpp>
constexpr long unsigned int WIDTH = 1920;
constexpr long unsigned int HEIGHT = 1080;
@ -17,10 +17,10 @@ constexpr int GLOW_KERNEL_SIZE = std::max(int(DIAG / 138 % 2 == 0 ? DIAG / 138 +
using std::cerr;
using std::endl;
static cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Tetra Demo");
static cv::Ptr<cv::viz::V4D> v2d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Tetra Demo");
void init_scene(const cv::Size& sz) {
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
//Initialize the OpenGL scene
glViewport(0, 0, sz.width, sz.height);
glColor3f(1.0, 1.0, 1.0);
@ -41,7 +41,7 @@ void init_scene(const cv::Size& sz) {
}
void render_scene(const cv::Size& sz) {
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
//Render a tetrahedron using immediate mode because the code is more concise for a demo
glViewport(0, 0, sz.width, sz.height);
glRotatef(1, 0, 1, 0);

@ -1,5 +1,5 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/viz2d/nvg.hpp>
#include <opencv2/v4d/v4d.hpp>
#include <opencv2/v4d/nvg.hpp>
using namespace cv;
using namespace cv::viz;
@ -8,7 +8,7 @@ constexpr int WIDTH = 1280;
constexpr int HEIGHT = 720;
int main(int argc, char** argv) {
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "Vector Graphics");
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "Vector Graphics");
//Creates a NanoVG context and draws a cross-hair on the framebuffer
v2d->nvg([](const Size& sz) {
//Calls from this namespace may only be used inside a nvg context

@ -1,5 +1,5 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/viz2d/nvg.hpp>
#include <opencv2/v4d/v4d.hpp>
#include <opencv2/v4d/nvg.hpp>
using namespace cv;
using namespace cv::viz;
@ -8,7 +8,7 @@ constexpr int WIDTH = 1280;
constexpr int HEIGHT = 720;
int main(int argc, char** argv) {
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "Vector Graphics and Framebuffer");
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "Vector Graphics and Framebuffer");
//Creates a NanoVG context and draws a cross-hair on the framebuffer
v2d->nvg([](const Size& sz) {
//Calls from this namespace may only be used inside a nvg context

@ -9,7 +9,7 @@ DEPS := ${SRCS:.cpp=.dep}
CXXFLAGS += -fpic
LDFLAGS +=
LIBS += -lm -lopencv_viz2d -lopencv_viz2d
LIBS += -lm -lopencv_v4d -lopencv_v4d
.PHONY: all release debug clean distclean
all: release

@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/v4d/v4d.hpp"
#include <string>
@ -18,10 +18,10 @@ using std::cerr;
using std::endl;
using std::string;
static cv::Ptr<cv::viz::Viz2D> v2d = cv::viz::Viz2D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Video Demo");
static cv::Ptr<cv::viz::V4D> v2d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Video Demo");
void init_scene(const cv::Size& sz) {
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
//Initialize the OpenGL scene
glViewport(0, 0, sz.width, sz.height);
glColor3f(1.0, 1.0, 1.0);
@ -42,7 +42,7 @@ void init_scene(const cv::Size& sz) {
}
void render_scene(const cv::Size& sz) {
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
//Render a tetrahedron using immediate mode because the code is more concise for a demo
glViewport(0, 0, sz.width, sz.height);
glRotatef(1, 0, 1, 0);

@ -1,5 +1,5 @@
#include <opencv2/viz2d/viz2d.hpp>
#include <opencv2/viz2d/nvg.hpp>
#include <opencv2/v4d/v4d.hpp>
#include <opencv2/v4d/nvg.hpp>
using namespace cv;
using namespace cv::viz;
@ -9,7 +9,7 @@ constexpr int HEIGHT = 720;
int main(int argc, char** argv) {
string hv = "Hello Video!";
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "Video Editing");
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "Video Editing");
//Make the video source
Source src = makeCaptureSource(argv[1]);
//Make the video sink

@ -5,7 +5,7 @@
#include "clvacontext.hpp"
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/v4d/v4d.hpp"
namespace cv {
namespace viz {

@ -10,14 +10,14 @@
namespace cv {
namespace viz {
class Viz2D;
class V4D;
namespace detail {
/*!
* Provides a context for OpenCL-VAAPI sharing
*/
class CLVAContext {
friend class cv::viz::Viz2D;
friend class cv::viz::V4D;
CLExecContext_t context_;
FrameBufferContext& clglContext_;
cv::UMat videoFrame_;

@ -5,10 +5,10 @@
#include "framebuffercontext.hpp"
#include "opencv2/viz2d/util.hpp"
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/v4d/util.hpp"
#include "opencv2/v4d/v4d.hpp"
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
#include <GL/glew.h>
#endif
@ -19,7 +19,7 @@ namespace detail {
//FIXME use cv::ogl
FrameBufferContext::FrameBufferContext(const cv::Size& frameBufferSize) :
frameBufferSize_(frameBufferSize) {
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
glewExperimental = true;
glewInit();
try {

@ -10,9 +10,9 @@
#include <CL/cl.h>
#include <CL/cl_gl.h>
#else
#define VIZ2D_USE_ES3 1
#define V4D_USE_ES3 1
#endif
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
# include <GL/glew.h>
# define GLFW_INCLUDE_GLCOREARB
#else
@ -24,11 +24,11 @@
#include <opencv2/core/opengl.hpp>
#include <iostream>
#include "opencv2/viz2d/util.hpp"
#include "opencv2/v4d/util.hpp"
namespace cv {
namespace viz {
class Viz2D;
class V4D;
namespace detail {
typedef cv::ocl::OpenCLExecutionContext CLExecContext_t;
typedef cv::ocl::OpenCLExecutionContextScope CLExecScope_t;
@ -39,7 +39,7 @@ typedef cv::ocl::OpenCLExecutionContextScope CLExecScope_t;
class FrameBufferContext {
friend class CLVAContext;
friend class NanoVGContext;
friend class cv::viz::Viz2D;
friend class cv::viz::V4D;
bool clglSharing_ = true;
GLuint frameBufferID_ = 0;
GLuint textureID_ = 0;

@ -5,12 +5,12 @@
#include "nanovgcontext.hpp"
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/v4d/v4d.hpp"
namespace cv {
namespace viz {
namespace detail {
NanoVGContext::NanoVGContext(Viz2D& v2d, NVGcontext* context, FrameBufferContext& fbContext) :
NanoVGContext::NanoVGContext(V4D& v2d, NVGcontext* context, FrameBufferContext& fbContext) :
v2d_(v2d), context_(context), clglContext_(fbContext) {
//FIXME workaround for first frame color glitch
cv::UMat tmp;
@ -27,7 +27,7 @@ void NanoVGContext::render(std::function<void(const cv::Size&)> fn) {
}
void push() {
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
GL_CHECK(glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS));
GL_CHECK(glPushAttrib(GL_ALL_ATTRIB_BITS));
GL_CHECK(glMatrixMode(GL_MODELVIEW));
@ -40,7 +40,7 @@ void push() {
}
void pop() {
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
GL_CHECK(glMatrixMode(GL_TEXTURE));
GL_CHECK(glPopMatrix());
GL_CHECK(glMatrixMode(GL_PROJECTION));

@ -6,10 +6,10 @@
#ifndef SRC_COMMON_NANOVGCONTEXT_HPP_
#define SRC_COMMON_NANOVGCONTEXT_HPP_
#ifdef __EMSCRIPTEN__
#define VIZ2D_USE_ES3 1
#define V4D_USE_ES3 1
#endif
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
#define NANOGUI_USE_OPENGL
#else
#define NANOGUI_USE_GLES
@ -18,8 +18,8 @@
#include "framebuffercontext.hpp"
#include <nanogui/nanogui.h>
#include <nanogui/opengl.h>
#include "opencv2/viz2d/util.hpp"
#include "opencv2/viz2d/nvg.hpp"
#include "opencv2/v4d/util.hpp"
#include "opencv2/v4d/nvg.hpp"
namespace cv {
namespace viz {
@ -28,7 +28,7 @@ namespace detail {
* Used to setup a nanovg context
*/
class NanoVGContext {
Viz2D& v2d_;
V4D& v2d_;
NVGcontext* context_;
FrameBufferContext& clglContext_;
public:
@ -55,11 +55,11 @@ public:
};
/*!
* Creates a NanoVGContext
* @param v2d The Viz2D object used in conjunction with this context
* @param v2d The V4D object used in conjunction with this context
* @param context The native NVGContext
* @param fbContext The framebuffer context
*/
NanoVGContext(Viz2D& v2d, NVGcontext* context, FrameBufferContext& fbContext);
NanoVGContext(V4D& v2d, NVGcontext* context, FrameBufferContext& fbContext);
/*!
* Execute function object fn inside a nanovg context.
* The context takes care of setting up opengl and nanovg states.

@ -3,12 +3,12 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/dialog.hpp"
#include "opencv2/v4d/dialog.hpp"
#include <nanogui/layout.h>
#ifdef __EMSCRIPTEN__
#define VIZ2D_USE_ES3 1
#define V4D_USE_ES3 1
#endif
#ifndef VIZ2D_USE_ES3
#ifndef V4D_USE_ES3
# include <GL/glew.h>
# define GLFW_INCLUDE_GLCOREARB
#else
@ -20,11 +20,11 @@
namespace cv {
namespace viz {
std::function<bool(Dialog*, Dialog*)> Dialog::viz2DWin_Xcomparator([](Dialog* lhs, Dialog* rhs) {
std::function<bool(Dialog*, Dialog*)> Dialog::v4dWin_Xcomparator([](Dialog* lhs, Dialog* rhs) {
return lhs->position()[0] < rhs->position()[0];
});
std::set<Dialog*, decltype(Dialog::viz2DWin_Xcomparator)> Dialog::all_windows_xsorted_(
viz2DWin_Xcomparator);
std::set<Dialog*, decltype(Dialog::v4dWin_Xcomparator)> Dialog::all_windows_xsorted_(
v4dWin_Xcomparator);
Dialog::Dialog(nanogui::Screen* screen, int x, int y, const string& title) :
Window(screen, title), screen_(screen), lastDragPos_(x, y) {

@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/formhelper.hpp"
#include "opencv2/v4d/formhelper.hpp"
namespace cv {
namespace viz {

@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/nvg.hpp"
#include "opencv2/v4d/nvg.hpp"
namespace cv {
namespace viz {

@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/sink.hpp"
#include "opencv2/v4d/sink.hpp"
namespace cv {
namespace viz {
@ -32,5 +32,5 @@ bool Sink::isOpen() {
void Sink::operator()(const cv::UMat& frame) {
open_ = consumer_(frame);
}
} /* namespace viz2d */
} /* namespace v4d */
} /* namespace kb */

@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/source.hpp"
#include "opencv2/v4d/source.hpp"
namespace cv {
namespace viz {
@ -38,5 +38,5 @@ std::pair<uint64_t, cv::UMat&> Source::operator()() {
open_ = generator_(frame_);
return {count_++, frame_};
}
} /* namespace viz2d */
} /* namespace v4d */
} /* namespace kb */

@ -3,10 +3,10 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/util.hpp"
#include "opencv2/v4d/util.hpp"
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/viz2d/nvg.hpp"
#include "opencv2/v4d/v4d.hpp"
#include "opencv2/v4d/nvg.hpp"
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
@ -134,10 +134,10 @@ bool keepRunning() {
/*!
* Little helper function to keep track of FPS and optionally display it using NanoVG
* @param v2d The Viz2D object to operate on
* @param v2d The V4D object to operate on
* @param graphical if this parameter is true the FPS drawn on display
*/
void updateFps(cv::Ptr<cv::viz::Viz2D> v2d, bool graphical) {
void updateFps(cv::Ptr<cv::viz::V4D> v2d, bool graphical) {
static uint64_t cnt = 0;
static cv::TickMeter tick;
static float fps;
@ -258,7 +258,7 @@ Source makeCaptureSource(int width, int height) {
cv::UMat frame = array.getUMat();
if (frame.empty())
frame.create(cv::Size(width, height), CV_8UC3);
std::ifstream fs("viz2d_rgba_canvas.raw", std::fstream::in | std::fstream::binary);
std::ifstream fs("v4d_rgba_canvas.raw", std::fstream::in | std::fstream::binary);
fs.seekg(0, std::ios::end);
auto length = fs.tellg();
fs.seekg(0, std::ios::beg);

@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
// Copyright Amir Hassan (kallaballa) <amir@viel-zu.org>
#include "opencv2/viz2d/viz2d.hpp"
#include "opencv2/v4d/v4d.hpp"
#include "detail/clvacontext.hpp"
#include "detail/framebuffercontext.hpp"
#include "detail/nanovgcontext.hpp"
@ -65,18 +65,18 @@ void resizeKeepAspectRatio(const cv::UMat& src, cv::UMat& output, const cv::Size
cv::copyMakeBorder(output, output, top, down, left, right, cv::BORDER_CONSTANT, bgcolor);
}
cv::Ptr<Viz2D> Viz2D::make(const cv::Size& size, const string& title, bool debug) {
cv::Ptr<Viz2D> v2d = new Viz2D(size, size, false, title, 4, 6, true, 0, debug);
cv::Ptr<V4D> V4D::make(const cv::Size& size, const string& title, bool debug) {
cv::Ptr<V4D> v2d = new V4D(size, size, false, title, 4, 6, true, 0, debug);
v2d->setVisible(true);
return v2d;
}
cv::Ptr<Viz2D> Viz2D::make(const cv::Size& initialSize, const cv::Size& frameBufferSize,
cv::Ptr<V4D> V4D::make(const cv::Size& initialSize, const cv::Size& frameBufferSize,
bool offscreen, const string& title, int major, int minor, bool compat, int samples, bool debug) {
return new Viz2D(initialSize, frameBufferSize, offscreen, title, major, minor, compat, samples, debug);
return new V4D(initialSize, frameBufferSize, offscreen, title, major, minor, compat, samples, debug);
}
Viz2D::Viz2D(const cv::Size& size, const cv::Size& frameBufferSize, bool offscreen,
V4D::V4D(const cv::Size& size, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major, int minor, bool compat, int samples, bool debug) :
initialSize_(size), frameBufferSize_(frameBufferSize), viewport_(0, 0,
frameBufferSize.width, frameBufferSize.height), scale_(1), mousePos_(0, 0), offscreen_(
@ -89,7 +89,7 @@ Viz2D::Viz2D(const cv::Size& size, const cv::Size& frameBufferSize, bool offscre
initializeWindowing();
}
Viz2D::~Viz2D() {
V4D::~V4D() {
//don't delete form_. it is autmatically cleaned up by the base class (nanogui::Screen)
if (screen_)
delete screen_;
@ -105,7 +105,7 @@ Viz2D::~Viz2D() {
delete clglContext_;
}
bool Viz2D::initializeWindowing() {
bool V4D::initializeWindowing() {
if (glfwInit() != GLFW_TRUE)
return false;
@ -124,7 +124,7 @@ bool Viz2D::initializeWindowing() {
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#elif defined(VIZ2D_USE_ES3)
#elif defined(V4D_USE_ES3)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
@ -172,7 +172,7 @@ bool Viz2D::initializeWindowing() {
glfwSetWindowUserPointer(getGLFWWindow(), this);
glfwSetCursorPosCallback(getGLFWWindow(), [](GLFWwindow* glfwWin, double x, double y) {
Viz2D* v2d = reinterpret_cast<Viz2D*>(glfwGetWindowUserPointer(glfwWin));
V4D* v2d = reinterpret_cast<V4D*>(glfwGetWindowUserPointer(glfwWin));
v2d->screen().cursor_pos_callback_event(x, y);
auto cursor = v2d->getMousePosition();
auto diff = cursor - cv::Vec2f(x, y);
@ -184,7 +184,7 @@ bool Viz2D::initializeWindowing() {
);
glfwSetMouseButtonCallback(getGLFWWindow(),
[](GLFWwindow* glfwWin, int button, int action, int modifiers) {
Viz2D* v2d = reinterpret_cast<Viz2D*>(glfwGetWindowUserPointer(glfwWin));
V4D* v2d = reinterpret_cast<V4D*>(glfwGetWindowUserPointer(glfwWin));
v2d->screen().mouse_button_callback_event(button, action, modifiers);
if (button == GLFW_MOUSE_BUTTON_RIGHT) {
v2d->setMouseDrag(action == GLFW_PRESS);
@ -193,23 +193,23 @@ bool Viz2D::initializeWindowing() {
);
glfwSetKeyCallback(getGLFWWindow(),
[](GLFWwindow* glfwWin, int key, int scancode, int action, int mods) {
Viz2D* v2d = reinterpret_cast<Viz2D*>(glfwGetWindowUserPointer(glfwWin));
V4D* v2d = reinterpret_cast<V4D*>(glfwGetWindowUserPointer(glfwWin));
v2d->screen().key_callback_event(key, scancode, action, mods);
}
);
glfwSetCharCallback(getGLFWWindow(), [](GLFWwindow* glfwWin, unsigned int codepoint) {
Viz2D* v2d = reinterpret_cast<Viz2D*>(glfwGetWindowUserPointer(glfwWin));
V4D* v2d = reinterpret_cast<V4D*>(glfwGetWindowUserPointer(glfwWin));
v2d->screen().char_callback_event(codepoint);
}
);
glfwSetDropCallback(getGLFWWindow(),
[](GLFWwindow* glfwWin, int count, const char** filenames) {
Viz2D* v2d = reinterpret_cast<Viz2D*>(glfwGetWindowUserPointer(glfwWin));
V4D* v2d = reinterpret_cast<V4D*>(glfwGetWindowUserPointer(glfwWin));
v2d->screen().drop_callback_event(count, filenames);
}
);
glfwSetScrollCallback(getGLFWWindow(), [](GLFWwindow* glfwWin, double x, double y) {
Viz2D* v2d = reinterpret_cast<Viz2D*>(glfwGetWindowUserPointer(glfwWin));
V4D* v2d = reinterpret_cast<V4D*>(glfwGetWindowUserPointer(glfwWin));
std::vector<nanogui::Widget*> widgets;
find_widgets(&v2d->screen(), widgets);
for (auto* w : widgets) {
@ -231,7 +231,7 @@ bool Viz2D::initializeWindowing() {
// );
glfwSetFramebufferSizeCallback(getGLFWWindow(), [](GLFWwindow* glfwWin, int width, int height) {
Viz2D* v2d = reinterpret_cast<Viz2D*>(glfwGetWindowUserPointer(glfwWin));
V4D* v2d = reinterpret_cast<V4D*>(glfwGetWindowUserPointer(glfwWin));
v2d->screen().resize_callback_event(width, height);
});
@ -241,54 +241,54 @@ bool Viz2D::initializeWindowing() {
return true;
}
cv::ogl::Texture2D& Viz2D::texture() {
cv::ogl::Texture2D& V4D::texture() {
return clglContext_->getTexture2D();
}
FormHelper& Viz2D::form() {
FormHelper& V4D::form() {
return *form_;
}
void Viz2D::setKeyboardEventCallback(
void V4D::setKeyboardEventCallback(
std::function<bool(int key, int scancode, int action, int modifiers)> fn) {
keyEventCb_ = fn;
}
bool Viz2D::keyboard_event(int key, int scancode, int action, int modifiers) {
bool V4D::keyboard_event(int key, int scancode, int action, int modifiers) {
if (keyEventCb_)
return keyEventCb_(key, scancode, action, modifiers);
return screen().keyboard_event(key, scancode, action, modifiers);
}
FrameBufferContext& Viz2D::fb() {
FrameBufferContext& V4D::fb() {
assert(clglContext_ != nullptr);
makeCurrent();
return *clglContext_;
}
CLVAContext& Viz2D::clva() {
CLVAContext& V4D::clva() {
assert(clvaContext_ != nullptr);
return *clvaContext_;
}
NanoVGContext& Viz2D::nvg() {
NanoVGContext& V4D::nvg() {
assert(nvgContext_ != nullptr);
makeCurrent();
return *nvgContext_;
}
nanogui::Screen& Viz2D::screen() {
nanogui::Screen& V4D::screen() {
assert(screen_ != nullptr);
makeCurrent();
return *screen_;
}
cv::Size Viz2D::getVideoFrameSize() {
cv::Size V4D::getVideoFrameSize() {
return clva().getVideoFrameSize();
}
void Viz2D::gl(std::function<void(const cv::Size&)> fn) {
void V4D::gl(std::function<void(const cv::Size&)> fn) {
auto fbSize = getFrameBufferSize();
#ifndef __EMSCRIPTEN__
detail::CLExecScope_t scope(fb().getCLExecContext());
@ -297,21 +297,21 @@ void Viz2D::gl(std::function<void(const cv::Size&)> fn) {
fn(fbSize);
}
void Viz2D::fb(std::function<void(cv::UMat&)> fn) {
void V4D::fb(std::function<void(cv::UMat&)> fn) {
fb().execute(fn);
}
void Viz2D::nvg(std::function<void(const cv::Size&)> fn) {
void V4D::nvg(std::function<void(const cv::Size&)> fn) {
nvg().render(fn);
}
void Viz2D::nanogui(std::function<void(FormHelper& form)> fn) {
void V4D::nanogui(std::function<void(FormHelper& form)> fn) {
fn(form());
screen().set_visible(true);
screen().perform_layout();
}
void Viz2D::run(std::function<bool()> fn) {
void V4D::run(std::function<bool()> fn) {
#ifndef __EMSCRIPTEN__
while (keepRunning() && fn())
;
@ -320,26 +320,26 @@ void Viz2D::run(std::function<bool()> fn) {
#endif
}
void Viz2D::setSource(const Source& src) {
void V4D::setSource(const Source& src) {
if (!clva().hasContext())
clva().copyContext();
source_ = src;
}
void Viz2D::feed(cv::InputArray& in) {
void V4D::feed(cv::InputArray& in) {
this->capture([&](cv::OutputArray& videoFrame) {
in.getUMat().copyTo(videoFrame);
});
}
bool Viz2D::capture() {
bool V4D::capture() {
return this->capture([&](cv::UMat& videoFrame) {
if (source_.isReady())
source_().second.copyTo(videoFrame);
});
}
bool Viz2D::capture(std::function<void(cv::UMat&)> fn) {
bool V4D::capture(std::function<void(cv::UMat&)> fn) {
if(futureReader_.valid())
if(!futureReader_.get())
return false;
@ -363,24 +363,24 @@ bool Viz2D::capture(std::function<void(cv::UMat&)> fn) {
return captureSuccessful_;
}
bool Viz2D::isSourceReady() {
bool V4D::isSourceReady() {
return source_.isReady();
}
void Viz2D::setSink(const Sink& sink) {
void V4D::setSink(const Sink& sink) {
if (!clva().hasContext())
clva().copyContext();
sink_ = sink;
}
void Viz2D::write() {
void V4D::write() {
this->write([&](const cv::UMat& videoFrame) {
if (sink_.isReady())
sink_(videoFrame);
});
}
void Viz2D::write(std::function<void(const cv::UMat&)> fn) {
void V4D::write(std::function<void(const cv::UMat&)> fn) {
if(futureWriter_.valid())
futureWriter_.get();
@ -395,19 +395,19 @@ void Viz2D::write(std::function<void(const cv::UMat&)> fn) {
});
}
bool Viz2D::isSinkReady() {
bool V4D::isSinkReady() {
return sink_.isReady();
}
void Viz2D::makeCurrent() {
void V4D::makeCurrent() {
glfwMakeContextCurrent(getGLFWWindow());
}
void Viz2D::makeNoneCurrent() {
void V4D::makeNoneCurrent() {
glfwMakeContextCurrent(nullptr);
}
void Viz2D::clear(const cv::Scalar& bgra) {
void V4D::clear(const cv::Scalar& bgra) {
const float& b = bgra[0] / 255.0f;
const float& g = bgra[1] / 255.0f;
const float& r = bgra[2] / 255.0f;
@ -416,27 +416,27 @@ void Viz2D::clear(const cv::Scalar& bgra) {
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT));
}
void Viz2D::showGui(bool s) {
void V4D::showGui(bool s) {
auto children = screen().children();
for (auto* child : children) {
child->set_visible(s);
}
}
void Viz2D::setMouseDrag(bool d) {
void V4D::setMouseDrag(bool d) {
mouseDrag_ = d;
}
bool Viz2D::isMouseDrag() {
bool V4D::isMouseDrag() {
return mouseDrag_;
}
void Viz2D::pan(int x, int y) {
void V4D::pan(int x, int y) {
viewport_.x += x * scale_;
viewport_.y += y * scale_;
}
void Viz2D::zoom(float factor) {
void V4D::zoom(float factor) {
if (scale_ == 1 && viewport_.x == 0 && viewport_.y == 0 && factor > 1)
return;
@ -501,52 +501,52 @@ void Viz2D::zoom(float factor) {
}
}
cv::Vec2f Viz2D::getPosition() {
cv::Vec2f V4D::getPosition() {
makeCurrent();
int x, y;
glfwGetWindowPos(getGLFWWindow(), &x, &y);
return {float(x), float(y)};
}
cv::Vec2f Viz2D::getMousePosition() {
cv::Vec2f V4D::getMousePosition() {
return mousePos_;
}
void Viz2D::setMousePosition(int x, int y) {
void V4D::setMousePosition(int x, int y) {
mousePos_ = { float(x), float(y) };
}
float Viz2D::getScale() {
float V4D::getScale() {
return scale_;
}
cv::Rect Viz2D::getViewport() {
cv::Rect V4D::getViewport() {
return viewport_;
}
cv::Size Viz2D::getNativeFrameBufferSize() {
cv::Size V4D::getNativeFrameBufferSize() {
makeCurrent();
int w, h;
glfwGetFramebufferSize(getGLFWWindow(), &w, &h);
return {w, h};
}
cv::Size Viz2D::getFrameBufferSize() {
cv::Size V4D::getFrameBufferSize() {
return frameBufferSize_;
}
cv::Size Viz2D::getWindowSize() {
cv::Size V4D::getWindowSize() {
makeCurrent();
int w, h;
glfwGetWindowSize(getGLFWWindow(), &w, &h);
return {w, h};
}
cv::Size Viz2D::getInitialSize() {
cv::Size V4D::getInitialSize() {
return initialSize_;
}
float Viz2D::getXPixelRatio() {
float V4D::getXPixelRatio() {
makeCurrent();
#ifdef __EMSCRIPTEN__
return emscripten_get_device_pixel_ratio();
@ -557,7 +557,7 @@ float Viz2D::getXPixelRatio() {
#endif
}
float Viz2D::getYPixelRatio() {
float V4D::getYPixelRatio() {
makeCurrent();
#ifdef __EMSCRIPTEN__
return emscripten_get_device_pixel_ratio();
@ -568,17 +568,17 @@ float Viz2D::getYPixelRatio() {
#endif
}
void Viz2D::setWindowSize(const cv::Size& sz) {
void V4D::setWindowSize(const cv::Size& sz) {
makeCurrent();
screen().set_size(nanogui::Vector2i(sz.width / getXPixelRatio(), sz.height / getYPixelRatio()));
}
bool Viz2D::isFullscreen() {
bool V4D::isFullscreen() {
makeCurrent();
return glfwGetWindowMonitor(getGLFWWindow()) != nullptr;
}
void Viz2D::setFullscreen(bool f) {
void V4D::setFullscreen(bool f) {
makeCurrent();
auto monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
@ -593,46 +593,46 @@ void Viz2D::setFullscreen(bool f) {
}
}
bool Viz2D::isResizable() {
bool V4D::isResizable() {
makeCurrent();
return glfwGetWindowAttrib(getGLFWWindow(), GLFW_RESIZABLE) == GLFW_TRUE;
}
void Viz2D::setResizable(bool r) {
void V4D::setResizable(bool r) {
makeCurrent();
glfwWindowHint(GLFW_RESIZABLE, r ? GLFW_TRUE : GLFW_FALSE);
}
bool Viz2D::isVisible() {
bool V4D::isVisible() {
makeCurrent();
return glfwGetWindowAttrib(getGLFWWindow(), GLFW_VISIBLE) == GLFW_TRUE;
}
void Viz2D::setVisible(bool v) {
void V4D::setVisible(bool v) {
makeCurrent();
glfwWindowHint(GLFW_VISIBLE, v ? GLFW_TRUE : GLFW_FALSE);
screen().set_visible(v);
screen().perform_layout();
}
bool Viz2D::isOffscreen() {
bool V4D::isOffscreen() {
return offscreen_;
}
void Viz2D::setOffscreen(bool o) {
void V4D::setOffscreen(bool o) {
offscreen_ = o;
setVisible(!o);
}
void Viz2D::setStretching(bool s) {
void V4D::setStretching(bool s) {
stretch_ = s;
}
bool Viz2D::isStretching() {
bool V4D::isStretching() {
return stretch_;
}
void Viz2D::setDefaultKeyboardEventCallback() {
void V4D::setDefaultKeyboardEventCallback() {
setKeyboardEventCallback([&](int key, int scancode, int action, int modifiers) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
setOffscreen(!isOffscreen());
@ -649,7 +649,7 @@ void Viz2D::setDefaultKeyboardEventCallback() {
});
}
bool Viz2D::display() {
bool V4D::display() {
bool result = true;
if (!offscreen_) {
makeCurrent();
@ -668,20 +668,20 @@ bool Viz2D::display() {
return result;
}
bool Viz2D::isClosed() {
bool V4D::isClosed() {
return closed_;
}
void Viz2D::close() {
void V4D::close() {
setVisible(false);
closed_ = true;
}
GLFWwindow* Viz2D::getGLFWWindow() {
GLFWwindow* V4D::getGLFWWindow() {
return glfwWindow_;
}
NVGcontext* Viz2D::getNVGcontext() {
NVGcontext* V4D::getNVGcontext() {
return screen().nvg_context();
}
}

@ -1,4 +1,4 @@
# Viz2D {#viz2d}
# V4D {#v4d}
[TOC]
@ -7,15 +7,15 @@
| Original author | Amir Hassan (kallaballa) <amir@viel-zu.org> |
| Compatibility | OpenCV >= 4.7 |
# What is Viz2D?
Viz2D offers a way of writing graphical (on- and offscreen) high performance applications with OpenCV. It is light-weight and unencumbered by QT or GTK licenses. It features vector graphics using [NanoVG](https://github.com/inniyah/nanovg) a GUI based on [NanoGUI](https://github.com/mitsuba-renderer/nanogui) and (on supported systems) OpenCL/OpenGL and OpenCL/VAAPI interoperability. It should be included in [OpenCV-contrib](https://github.com/opencv/opencv_contrib) once it is ready.
# What is V4D?
V4D offers a way of writing graphical (on- and offscreen) high performance applications with OpenCV. It is light-weight and unencumbered by QT or GTK licenses. It features vector graphics using [NanoVG](https://github.com/inniyah/nanovg) a GUI based on [NanoGUI](https://github.com/mitsuba-renderer/nanogui) and (on supported systems) OpenCL/OpenGL and OpenCL/VAAPI interoperability. It should be included in [OpenCV-contrib](https://github.com/opencv/opencv_contrib) once it is ready.
# Showcase
Please note that all renderings and videos were created on an Intel Tigerlake CPU and an Intel Iris Xe iGPU. Also the demos in the videos might run slower for various reasons (better implementation by now, screen capturing, etc.) than they would normally do.
@youtube{yYnWkkZSK7Q}
# Why Viz2D?
# Why V4D?
Please refer to the online demos in the following section to see at a glance what it can do for you.
* **OpenGL**: Easy access to OpenGL.
@ -36,16 +36,16 @@ Please note that the following online demos are slower and/or have less features
* https://viel-zu.org/opencv/beauty
# Design Notes
* Viz2D is not thread safe. Though it is possible to have several Viz2D objects in one or more threads and synchronize them using ```Viz2D::makeNonCurrent()``` and ```Viz2D::makeCurrent()```. This is a limitation of GLFW3. That said, OpenCV algorithms are multi-threaded as usual.
* Viz2D uses InputArray/OutputArray/InputOutputArray which gives you the option to work with Mat, std::vector and UMat. Anyway, you should prefer to use UMat whenever possible to automatically use hardware capabilities where available.
* V4D is not thread safe. Though it is possible to have several V4D objects in one or more threads and synchronize them using ```V4D::makeNonCurrent()``` and ```V4D::makeCurrent()```. This is a limitation of GLFW3. That said, OpenCV algorithms are multi-threaded as usual.
* V4D uses InputArray/OutputArray/InputOutputArray which gives you the option to work with Mat, std::vector and UMat. Anyway, you should prefer to use UMat whenever possible to automatically use hardware capabilities where available.
* Access to different subsystems (opengl, framebuffer, nanovg and nanogui) is provided through "contexts". A context is simply a function that takes a functor, sets up the subsystem, executes the functor and tears-down the subsystem.
* ```Viz2D::run``` is not a context. It is an abstraction of a run loop that takes a functor and runs until the application terminates or the functor returns false. This is necessary for portability reasons.
* ```V4D::run``` is not a context. It is an abstraction of a run loop that takes a functor and runs until the application terminates or the functor returns false. This is necessary for portability reasons.
* Contexts ***may not*** be nested.
For example, to create an OpenGL context and set the GL viewport:
@code{.cpp}
//Creates a Viz2D object for on screen rendering
Ptr<Viz2D> v2d = Viz2D::make(Size(WIDTH, HEIGHT), "GL viewport");
//Creates a V4D object for on screen rendering
Ptr<V4D> v2d = V4D::make(Size(WIDTH, HEIGHT), "GL viewport");
//Takes care of OpenGL states in the background
v2d->gl([](const Size sz) {
@ -73,45 +73,45 @@ v2d->gl([](const Size sz) {
* If you want CL-GL sharing on a recent Intel Platform (Gen8 - Gen12) you currently **need to build** [compute-runtime](https://github.com/intel/compute-runtime) and [my OpenCV 4.x fork](https://github.com/kallaballa/opencv/tree/GCV)
# Tutorials
The tutorials are designed to be read one after the other to give you a good overview over the key concepts of Viz2D. After that you can move on to the samples.
The tutorials are designed to be read one after the other to give you a good overview over the key concepts of V4D. After that you can move on to the samples.
* \ref viz2d_display_image
* \ref viz2d_vector_graphics
* \ref viz2d_render_opengl
* \ref viz2d_font_rendering
* \ref viz2d_video_editing
* \ref viz2d_custom_source_and_sink
* \ref viz2d_font_with_gui
* \ref v4d_display_image
* \ref v4d_vector_graphics
* \ref v4d_render_opengl
* \ref v4d_font_rendering
* \ref v4d_video_editing
* \ref v4d_custom_source_and_sink
* \ref v4d_font_with_gui
# Samples
The goal of the samples is to show how to use Viz2D to the fullest. Also they show how to use Viz2D to create programs that run mostly (the part the matters) on the GPU (when driver capabilities allow). They are also a good starting point for your own applications because they touch many key aspects and algorithms of OpenCV.
The goal of the samples is to show how to use V4D to the fullest. Also they show how to use V4D to create programs that run mostly (the part the matters) on the GPU (when driver capabilities allow). They are also a good starting point for your own applications because they touch many key aspects and algorithms of OpenCV.
* \ref viz2d_tetra
* \ref viz2d_video
* \ref viz2d_nanovg
* \ref viz2d_shader
* \ref viz2d_font
* \ref viz2d_pedestrian
* \ref viz2d_optflow
* \ref viz2d_beauty
* \ref v4d_tetra
* \ref v4d_video
* \ref v4d_nanovg
* \ref v4d_shader
* \ref v4d_font
* \ref v4d_pedestrian
* \ref v4d_optflow
* \ref v4d_beauty
# Instructions for Ubuntu 22.04.2 LTS
You need to build OpenCV with Viz2D
You need to build OpenCV with V4D
## Install required packages
```bash
apt install vainfo clinfo libqt5opengl5-dev freeglut3-dev ocl-icd-opencl-dev libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev libglfw3-dev libstb-dev libglew-dev cmake make git-core build-essential opencl-clhpp-headers pkg-config zlib1g-dev doxygen libxinerama-dev libxcursor-dev libxi-dev libva-dev
```
## Build OpenCV with Viz2D
## Build OpenCV with V4D
```bash
git clone --branch 4.x https://github.com/opencv/opencv.git
git clone https://github.com/kallaballa/Viz2D.git
git clone https://github.com/kallaballa/V4D.git
mkdir opencv/build
cd opencv/build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_viz2d=ON -DBUILD_opencv_python_tests=OFF -DBUILD_opencv_js_bindings_generator=OFF -DBUILD_opencv_python_bindings_generator=OFF -DBUILD_opencv_python3=OFF -DOPENCV_ENABLE_GLX=ON -DOPENCV_FFMPEG_ENABLE_LIBAVDEVICE=ON -DWITH_OPENGL=ON -DWITH_QT=ON -DWITH_FFMPEG=ON -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON -DWITH_VA=ON -DWITH_VA_INTEL=ON -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DOPENCV_EXTRA_MODULES_PATH=../../Viz2D/modules/ ..
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_v4d=ON -DBUILD_opencv_python_tests=OFF -DBUILD_opencv_js_bindings_generator=OFF -DBUILD_opencv_python_bindings_generator=OFF -DBUILD_opencv_python3=OFF -DOPENCV_ENABLE_GLX=ON -DOPENCV_FFMPEG_ENABLE_LIBAVDEVICE=ON -DWITH_OPENGL=ON -DWITH_QT=ON -DWITH_FFMPEG=ON -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON -DWITH_VA=ON -DWITH_VA_INTEL=ON -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DOPENCV_EXTRA_MODULES_PATH=../../V4D/modules/ ..
make -j8
sudo make install
```
@ -130,7 +130,7 @@ sudo make install
### Make the samples
```bash
cd Viz2D/modules/viz2d/samples/cpp
cd V4D/modules/v4d/samples/cpp
make -j
```
@ -142,28 +142,28 @@ wget -O bunny.webm https://upload.wikimedia.org/wikipedia/commons/transcoded/f/f
### Run the samples
```bash
modules/viz2d/samples/cpp/tetra/tetra-demo
modules/v4d/samples/cpp/tetra/tetra-demo
```
```bash
modules/viz2d/samples/cpp/video/video-demo bunny.webm
modules/v4d/samples/cpp/video/video-demo bunny.webm
```
```bash
modules/viz2d/samples/cpp/shader/shader-demo bunny.webm
modules/v4d/samples/cpp/shader/shader-demo bunny.webm
```
```bash
modules/viz2d/samples/cpp/nanovg/nanovg-demo bunny.webm
modules/v4d/samples/cpp/nanovg/nanovg-demo bunny.webm
```
```bash
modules/viz2d/samples/cpp/font/font-demo
modules/v4d/samples/cpp/font/font-demo
```
```bash
modules/viz2d/samples/cpp/optflow/optflow-demo bunny.webm
modules/v4d/samples/cpp/optflow/optflow-demo bunny.webm
```
```bash
modules/viz2d/samples/cpp/pedestrian/pedestrian-demo bunny.webm
modules/v4d/samples/cpp/pedestrian/pedestrian-demo bunny.webm
```
```bash
modules/viz2d/samples/cpp/beauty/beauty-demo bunny.webm
modules/v4d/samples/cpp/beauty/beauty-demo bunny.webm
```
# Attribution

@ -1,7 +1,7 @@
# Display an Image {#viz2d_display_image}
# Display an Image {#v4d_display_image}
@prev_tutorial{viz2d}
@next_tutorial{viz2d_vector_graphics}
@prev_tutorial{v4d}
@next_tutorial{v4d_vector_graphics}
| | |
| -: | :- |
@ -9,7 +9,7 @@
| Compatibility | OpenCV >= 4.7 |
## Using the video pipeline
Actually there are two ways to display an image using Viz2D. The most convenient way is to use the video pipeline to feed an image to Viz2D. That has the advantage that the image is automatically resized (preserving aspect ratio) to framebuffer size and color converted (the framebuffer is BGRA).
Actually there are two ways to display an image using V4D. The most convenient way is to use the video pipeline to feed an image to V4D. That has the advantage that the image is automatically resized (preserving aspect ratio) to framebuffer size and color converted (the framebuffer is BGRA).
@include samples/cpp/display_image.cpp

@ -1,7 +1,7 @@
# Render vector graphics {#viz2d_vector_graphics}
# Render vector graphics {#v4d_vector_graphics}
@prev_tutorial{viz2d_display_image}
@next_tutorial{viz2d_render_opengl}
@prev_tutorial{v4d_display_image}
@next_tutorial{v4d_render_opengl}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# OpenGL Rendering {#viz2d_render_opengl}
# OpenGL Rendering {#v4d_render_opengl}
@prev_tutorial{viz2d_vector_graphics}
@next_tutorial{viz2d_font_rendering}
@prev_tutorial{v4d_vector_graphics}
@next_tutorial{v4d_font_rendering}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Font rendering {#viz2d_font_rendering}
# Font rendering {#v4d_font_rendering}
@prev_tutorial{viz2d_render_opengl}
@next_tutorial{viz2d_video_editing}
@prev_tutorial{v4d_render_opengl}
@next_tutorial{v4d_video_editing}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Video editing {#viz2d_video_editing}
# Video editing {#v4d_video_editing}
@prev_tutorial{viz2d_font_rendering}
@next_tutorial{viz2d_custom_source_and_sink}
@prev_tutorial{v4d_font_rendering}
@next_tutorial{v4d_custom_source_and_sink}
| | |
| -: | :- |

@ -0,0 +1,17 @@
# Custom Source and Sink {#v4d_custom_source_and_sink}
@prev_tutorial{v4d_video_editing}
@next_tutorial{v4d_font_with_gui}
| | |
| -: | :- |
| Original author | Amir Hassan (kallaballa) <amir@viel-zu.org> |
| Compatibility | OpenCV >= 4.7 |
## Reading and writing to V4D using custom Sources and Sinks
In the previous tutorial we used a default video source and a video sink to stream a video through V4D which can be manipulated using OpenGL, NanoVG or OpenCV. In this example we are creating a custom Source that generates rainbow frames. For each time the Source is invoked the frame is colored a slightly different color. Additionally the custom Sink saves individual images instead of a video.
@include samples/cpp/custom_source_and_sink.cpp
![The result](doc/custom_source_and_sink.png)

@ -1,6 +1,6 @@
# Form based GUI {#viz2d_font_with_gui}
# Form based GUI {#v4d_font_with_gui}
@prev_tutorial{viz2d_custom_source_and_sink}
@prev_tutorial{v4d_custom_source_and_sink}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Tetra-Demo {#viz2d_tetra}
# Tetra-Demo {#v4d_tetra}
@prev_tutorial{viz2d}
@next_tutorial{viz2d_video}
@prev_tutorial{v4d}
@next_tutorial{v4d_video}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Video-Demo {#viz2d_video}
# Video-Demo {#v4d_video}
@prev_tutorial{viz2d_tetra}
@next_tutorial{viz2d_nanovg}
@prev_tutorial{v4d_tetra}
@next_tutorial{v4d_nanovg}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Nanovg-Demo {#viz2d_nanovg}
# Nanovg-Demo {#v4d_nanovg}
@prev_tutorial{viz2d_video}
@next_tutorial{viz2d_shader}
@prev_tutorial{v4d_video}
@next_tutorial{v4d_shader}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Shader-Demo {#viz2d_shader}
# Shader-Demo {#v4d_shader}
@prev_tutorial{viz2d_nanovg}
@next_tutorial{viz2d_font}
@prev_tutorial{v4d_nanovg}
@next_tutorial{v4d_font}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Font-Demo {#viz2d_font}
# Font-Demo {#v4d_font}
@prev_tutorial{viz2d_shader}
@next_tutorial{viz2d_pedestrian}
@prev_tutorial{v4d_shader}
@next_tutorial{v4d_pedestrian}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Pedestrian-Demo {#viz2d_pedestrian}
# Pedestrian-Demo {#v4d_pedestrian}
@prev_tutorial{viz2d_font}
@next_tutorial{viz2d_optflow}
@prev_tutorial{v4d_font}
@next_tutorial{v4d_optflow}
| | |
| -: | :- |

@ -1,7 +1,7 @@
# Optflow-Demo {#viz2d_optflow}
# Optflow-Demo {#v4d_optflow}
@prev_tutorial{viz2d_pedestrian}
@next_tutorial{viz2d_beauty}
@prev_tutorial{v4d_pedestrian}
@next_tutorial{v4d_beauty}
| | |
| -: | :- |

@ -1,6 +1,6 @@
# Beauty-Demo {#viz2d_beauty}
# Beauty-Demo {#v4d_beauty}
@prev_tutorial{viz2d_optflow}
@prev_tutorial{v4d_optflow}
| | |
| -: | :- |

@ -1,17 +0,0 @@
# Custom Source and Sink {#viz2d_custom_source_and_sink}
@prev_tutorial{viz2d_video_editing}
@next_tutorial{viz2d_font_with_gui}
| | |
| -: | :- |
| Original author | Amir Hassan (kallaballa) <amir@viel-zu.org> |
| Compatibility | OpenCV >= 4.7 |
## Reading and writing to Viz2D using custom Sources and Sinks
In the previous tutorial we used a default video source and a video sink to stream a video through Viz2D which can be manipulated using OpenGL, NanoVG or OpenCV. In this example we are creating a custom Source that generates rainbow frames. For each time the Source is invoked the frame is colored a slightly different color. Additionally the custom Sink saves individual images instead of a video.
@include samples/cpp/custom_source_and_sink.cpp
![The result](doc/custom_source_and_sink.png)
Loading…
Cancel
Save