opencv/modules/highgui/cmake/init.cmake
kozinove efa4d9176a
Merge pull request #25661 from itlab-vision:framebuffer
Highgui backend on top of Framebuffer #25661

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [ x] I agree to contribute to the project under Apache 2 License.
- [ x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ x] The feature is well documented and sample code can be built with the project CMake

Environment variables used:
OPENCV_UI_BACKEND - you need to add the value “FB”
OPENCV_UI_PRIORITY_FB - requires priority indication
OPENCV_HIGHGUI_FB_MODE={FB|XVFB|EMU} - mode of using Framebuffer (default "FB")
- FB - Linux Framebuffer
- XVFB - virtual Framebuffer
- EMU - emulation (images are not displayed)
OPENCV_HIGHGUI_FB_DEVICE (FRAMEBUFFER) - path to the Framebuffer file (default "/dev/fb0").

Examples of using:

sudo OPENCV_UI_BACKEND=FB ./opencv_test_highgui
sudo OPENCV_UI_PRIORITY_FB=1111 ./opencv_test_highgui
OPENCV_UI_BACKEND=FB OPENCV_HIGHGUI_FB_MODE=EMU ./opencv_test_highgui
sudo OPENCV_UI_BACKEND=FB OPENCV_HIGHGUI_FB_MODE=FB ./opencv_test_highgui

export DISPLAY=:99
Xvfb $DISPLAY -screen 0 1024x768x24 -fbdir /tmp/ -f /tmp/user.xvfb.auth&
sudo -u sipeed XAUTHORITY=/tmp/user.xvfb.auth x11vnc -display $DISPLAY -listen localhost&
DISPLAY=:0 gvncviewer localhost&

FRAMEBUFFER=/tmp/Xvfb_screen0 OPENCV_UI_BACKEND=FB OPENCV_HIGHGUI_FB_MODE=XVFB ./opencv_test_highgui
2024-06-26 15:31:19 +03:00

49 lines
1.6 KiB
CMake

if(PROJECT_NAME STREQUAL "OpenCV")
set(ENABLE_PLUGINS_DEFAULT ON)
if(EMSCRIPTEN OR IOS OR WINRT)
set(ENABLE_PLUGINS_DEFAULT OFF)
endif()
set(HIGHGUI_PLUGIN_LIST "" CACHE STRING "List of GUI backends to be compiled as plugins (gtk, gtk2/gtk3, qt, win32 or special value 'all')")
set(HIGHGUI_ENABLE_PLUGINS "${ENABLE_PLUGINS_DEFAULT}" CACHE BOOL "Allow building and using of GUI plugins")
mark_as_advanced(HIGHGUI_PLUGIN_LIST HIGHGUI_ENABLE_PLUGINS)
string(REPLACE "," ";" HIGHGUI_PLUGIN_LIST "${HIGHGUI_PLUGIN_LIST}") # support comma-separated list (,) too
string(TOLOWER "${HIGHGUI_PLUGIN_LIST}" HIGHGUI_PLUGIN_LIST)
if(NOT HIGHGUI_ENABLE_PLUGINS)
if(HIGHGUI_PLUGIN_LIST)
message(WARNING "HighGUI: plugins are disabled through HIGHGUI_ENABLE_PLUGINS, so HIGHGUI_PLUGIN_LIST='${HIGHGUI_PLUGIN_LIST}' is ignored")
set(HIGHGUI_PLUGIN_LIST "")
endif()
else()
# Make virtual plugins target
if(NOT TARGET opencv_highgui_plugins)
add_custom_target(opencv_highgui_plugins ALL)
endif()
endif()
endif()
#
# Detect available dependencies
#
if(NOT PROJECT_NAME STREQUAL "OpenCV")
include(FindPkgConfig)
endif()
macro(add_backend backend_id cond_var)
if(${cond_var})
include("${CMAKE_CURRENT_LIST_DIR}/detect_${backend_id}.cmake")
endif()
endmacro()
add_backend("gtk" WITH_GTK)
add_backend("win32ui" WITH_WIN32UI)
add_backend("wayland" WITH_WAYLAND)
add_backend("framebuffer" WITH_FRAMEBUFFER)
# TODO cocoa
# TODO qt
# TODO opengl
# FIXIT: move content of cmake/OpenCVFindLibsGUI.cmake here (need to resolve CMake scope issues)