Repository for OpenCV's extra modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
kallaballa 865955cc07 Merge branch 'main' of github.com:kallaballa/Viz2D 2 years ago
assets added assets 2 years ago
modules/viz2d more precise includes 2 years ago
.gitignore updated gitignore 2 years ago
.gitmodules updated gitmodules 2 years ago
LICENSE switched LICENSE to Apache2 and added license headers in c++ files 2 years ago
README.md Update README.md 2 years ago
debug-env.sh updated debug env variables 3 years ago

README.md

Viz2D

Viz2D is a visualization module for OpenCV. It features vector graphics using NanoVG a GUI based on NanoGUI and (on supported systems) OpenCL/OpenGL and OpenCL/VAAPI interoperability. It should be included in 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.

Why Viz2D?

Please refer to the 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.
  • Vector graphics: Elegant and fast vector graphics through NanoVG.
  • Font rendering: Loading of TTF-fonts and sophisticated rendering options.
  • Video pipeline: Through a simple Source/Sink system videos can be displayed, edited and saved.
  • Hardware acceleration: Automatic hardware acceleration usage where possible. (e.g. cl-gl sharing and VAAPI). Actually it is possible to write programs that run almost entirely on the GPU, given driver-features are available.
  • No more highgui with it's heavy dependencies, licenses and limitations.
  • WebAssembly

Online Demos

Please note that the following online demos are slower and/or have less features than the native versions.

Documentation

OpenCV module documentation with tutorials and samples is available here

Build

Requirements

  • C++20 (at the moment)
  • OpenGL 4/OpenGL ES 3.0

Optional requirements

  • Support for OpenCL 1.2
  • Support for cl_khr_gl_sharing and cl_intel_va_api_media_sharing OpenCL extensions.
  • If you want cl-gl sharing on a recent Intel Platform (Gen8 - Gen12) you currently need to install compute-runtime from source and my OpenCV fork

Dependencies

Instructions for Ubuntu 22.04.2 LTS

You need to build OpenCV with Viz2D

Install required packages

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

Build OpenCV with Viz2D using C++20

git clone --branch 4.x https://github.com/opencv/opencv.git
git clone https://github.com/kallaballa/Viz2D.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/ ..
make -j8
sudo make install

Build the samples

cd Viz2D/modules/viz2d/samples/cpp
make -j

Download the example file

wget -O bunny.webm https://upload.wikimedia.org/wikipedia/commons/transcoded/f/f3/Big_Buck_Bunny_first_23_seconds_1080p.ogv/Big_Buck_Bunny_first_23_seconds_1080p.ogv.1080p.vp9.webm

Run the demos

Viz2D/modules/viz2d/samples/cpp/tetra/tetra-demo
Viz2D/modules/viz2d/samples/cpp/video/video-demo bunny.webm
Viz2D/modules/viz2d/samples/cpp/shader/shader-demo bunny.webm
Viz2D/modules/viz2d/samples/cpp/nanovg/nanovg-demo bunny.webm
Viz2D/modules/viz2d/samples/cpp/font/font-demo
Viz2D/modules/viz2d/samples/cpp/optflow/optflow-demo bunny.webm
Viz2D/modules/viz2d/samples/cpp/pedestrian/pedestrian-demo bunny.webm
Viz2D/modules/viz2d/samples/cpp/beauty/beauty-demo bunny.webm

Attribution

  • The author of the bunny video is (c) copyright Blender Foundation | www.bigbuckbunny.org.
  • The author of the dance video is GNI Dance Company (Original video)
  • The author of the video used in the beauty-demo video is Kristen Leanne (Original video)