feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
302
3rdparty/opencv-4.5.4/modules/highgui/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,302 @@
|
||||
set(the_description "High-level GUI")
|
||||
|
||||
if(ANDROID)
|
||||
ocv_add_module(highgui opencv_imgproc opencv_imgcodecs OPTIONAL opencv_videoio WRAP python)
|
||||
else()
|
||||
ocv_add_module(highgui opencv_imgproc opencv_imgcodecs OPTIONAL opencv_videoio WRAP python java)
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/plugin.cmake)
|
||||
|
||||
set(tgts "PRIVATE")
|
||||
|
||||
set(highgui_hdrs
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp
|
||||
)
|
||||
|
||||
set(highgui_srcs
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/backend.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/roiSelector.cpp
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for highgui. See root CMakeLists.txt
|
||||
# Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
|
||||
# Jose Luis Blanco, 2008
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if(DEFINED WINRT AND NOT DEFINED ENABLE_WINRT_MODE_NATIVE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_WEBP)
|
||||
add_definitions(-DHAVE_WEBP)
|
||||
endif()
|
||||
|
||||
file(GLOB highgui_ext_hdrs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h")
|
||||
|
||||
# Removing WinRT API headers by default
|
||||
list(REMOVE_ITEM highgui_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/highgui_winrt.hpp")
|
||||
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "")
|
||||
|
||||
if(HAVE_QT)
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "QT${QT_VERSION_MAJOR}")
|
||||
add_definitions(-DHAVE_QT)
|
||||
|
||||
if(QT_VERSION_MAJOR GREATER 4)
|
||||
# "Automoc" doesn't work properly with opencv_world build, use QT<ver>_WRAP_CPP() directly
|
||||
#set(CMAKE_AUTOMOC ON)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
if(QT_VERSION_MAJOR EQUAL 6)
|
||||
QT6_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
|
||||
QT6_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
|
||||
elseif(QT_VERSION_MAJOR EQUAL 5)
|
||||
QT5_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
|
||||
QT5_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsuported QT version: ${QT_VERSION_MAJOR}")
|
||||
endif()
|
||||
|
||||
list(APPEND highgui_srcs
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h
|
||||
${_MOC_OUTFILES}
|
||||
${_RCC_OUTFILES})
|
||||
|
||||
set(qt_deps Core Gui Widgets Test Concurrent)
|
||||
if(HAVE_QT_OPENGL)
|
||||
add_definitions(-DHAVE_QT_OPENGL)
|
||||
list(APPEND qt_deps OpenGL)
|
||||
endif()
|
||||
|
||||
foreach(dt_dep ${qt_deps})
|
||||
add_definitions(${Qt${QT_VERSION_MAJOR}${dt_dep}_DEFINITIONS})
|
||||
include_directories(${Qt${QT_VERSION_MAJOR}${dt_dep}_INCLUDE_DIRS})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${Qt${QT_VERSION_MAJOR}${dt_dep}_LIBRARIES})
|
||||
endforeach()
|
||||
else()
|
||||
ocv_assert(QT_VERSION_MAJOR EQUAL 4)
|
||||
if (HAVE_QT_OPENGL)
|
||||
set(QT_USE_QTOPENGL TRUE)
|
||||
endif()
|
||||
include(${QT_USE_FILE})
|
||||
|
||||
QT4_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
|
||||
QT4_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
|
||||
|
||||
list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES})
|
||||
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES})
|
||||
ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag "")
|
||||
if(${_have_flag})
|
||||
set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
|
||||
endif()
|
||||
endif()
|
||||
elseif(WINRT)
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "WINRT")
|
||||
if(NOT WINRT_8_0)
|
||||
# Dependencies used by the implementation referenced
|
||||
# below are not available on WinRT 8.0.
|
||||
# Enabling it for WiRT 8.1+ only.
|
||||
|
||||
# WinRT 8.1+ detected. Adding WinRT API header.
|
||||
message(STATUS " ${name}: WinRT detected. Adding WinRT API header")
|
||||
list(APPEND highgui_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/highgui_winrt.hpp")
|
||||
|
||||
|
||||
list(APPEND highgui_srcs
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_winrt.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_winrt_bridge.cpp)
|
||||
list(APPEND highgui_hdrs
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_winrt_bridge.hpp)
|
||||
endif()
|
||||
|
||||
# libraries below are neither available nor required
|
||||
# on ARM devices and/or Windows Phone
|
||||
if(WINRT_PHONE OR (OpenCV_ARCH STREQUAL "ARM"))
|
||||
list(REMOVE_ITEM HIGHGUI_LIBRARIES "comctl32" "gdi32" "ole32" "setupapi")
|
||||
if(WINRT_PHONE)
|
||||
message(STATUS " ${name}: Windows Phone detected")
|
||||
elseif(OpenCV_ARCH STREQUAL "ARM")
|
||||
message(STATUS " ${name}: ARM detected")
|
||||
if(WINRT_STORE)
|
||||
list(REMOVE_ITEM HIGHGUI_LIBRARIES "ws2_32")
|
||||
message(STATUS " ${name}: Removing 'ws2_32.lib'")
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS " ${name}: Removing 'comctl32.lib, gdi32.lib, ole32.lib, setupapi.lib'")
|
||||
message(STATUS " ${name}: Leaving '${HIGHGUI_LIBRARIES}'")
|
||||
endif()
|
||||
elseif(HAVE_COCOA)
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "COCOA")
|
||||
add_definitions(-DHAVE_COCOA)
|
||||
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_cocoa.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
if(TARGET ocv.3rdparty.win32ui)
|
||||
if("win32ui" IN_LIST HIGHGUI_PLUGIN_LIST OR HIGHGUI_PLUGIN_LIST STREQUAL "all")
|
||||
ocv_create_builtin_highgui_plugin(opencv_highgui_win32 ocv.3rdparty.win32ui "window_w32.cpp")
|
||||
elseif(NOT OPENCV_HIGHGUI_BUILTIN_BACKEND)
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "WIN32UI")
|
||||
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_w32.cpp)
|
||||
list(APPEND tgts ocv.3rdparty.win32ui)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET ocv.3rdparty.gtk3 OR TARGET ocv.3rdparty.gtk2)
|
||||
if(TARGET ocv.3rdparty.gtk3 AND NOT WITH_GTK_2_X)
|
||||
set(__gtk_dependency "ocv.3rdparty.gtk3")
|
||||
else()
|
||||
set(__gtk_dependency "ocv.3rdparty.gtk2")
|
||||
endif()
|
||||
if(
|
||||
NOT HIGHGUI_PLUGIN_LIST STREQUAL "all"
|
||||
AND NOT "gtk" IN_LIST HIGHGUI_PLUGIN_LIST
|
||||
AND NOT "gtk2" IN_LIST HIGHGUI_PLUGIN_LIST
|
||||
AND NOT "gtk3" IN_LIST HIGHGUI_PLUGIN_LIST
|
||||
AND NOT OPENCV_HIGHGUI_BUILTIN_BACKEND
|
||||
)
|
||||
if(__gtk_dependency STREQUAL "ocv.3rdparty.gtk3")
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "GTK3")
|
||||
elseif(__gtk_dependency STREQUAL "ocv.3rdparty.gtk2")
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "GTK2")
|
||||
else()
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "GTK")
|
||||
endif()
|
||||
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_gtk.cpp)
|
||||
list(APPEND tgts ${__gtk_dependency})
|
||||
if(TARGET ocv.3rdparty.gthread)
|
||||
list(APPEND tgts ocv.3rdparty.gthread)
|
||||
endif()
|
||||
if(TARGET ocv.3rdparty.gtkglext
|
||||
AND __gtk_dependency STREQUAL "ocv.3rdparty.gtk2"
|
||||
AND NOT OPENCV_GTK_DISABLE_GTKGLEXT
|
||||
)
|
||||
list(APPEND tgts ocv.3rdparty.gtkglext)
|
||||
if(TARGET ocv.3rdparty.gtk_opengl
|
||||
AND __gtk_dependency STREQUAL "ocv.3rdparty.gtk2"
|
||||
AND NOT OPENCV_GTK_DISABLE_OPENGL
|
||||
)
|
||||
list(APPEND tgts ocv.3rdparty.gtk_opengl)
|
||||
endif()
|
||||
endif()
|
||||
elseif("gtk" IN_LIST HIGHGUI_PLUGIN_LIST)
|
||||
ocv_create_builtin_highgui_plugin(opencv_highgui_gtk ${__gtk_dependency} "window_gtk.cpp")
|
||||
if(TARGET ocv.3rdparty.gthread)
|
||||
ocv_target_link_libraries(opencv_highgui_gtk ocv.3rdparty.gthread)
|
||||
endif()
|
||||
if(TARGET ocv.3rdparty.gtkglext)
|
||||
ocv_target_link_libraries(opencv_highgui_gtk ocv.3rdparty.gtkglext)
|
||||
endif()
|
||||
else()
|
||||
if(TARGET ocv.3rdparty.gtk3 AND ("gtk3" IN_LIST HIGHGUI_PLUGIN_LIST OR HIGHGUI_PLUGIN_LIST STREQUAL "all"))
|
||||
ocv_create_builtin_highgui_plugin(opencv_highgui_gtk3 ocv.3rdparty.gtk3 "window_gtk.cpp")
|
||||
if(TARGET ocv.3rdparty.gthread)
|
||||
ocv_target_link_libraries(opencv_highgui_gtk3 ocv.3rdparty.gthread)
|
||||
endif()
|
||||
if(TARGET ocv.3rdparty.gtkglext)
|
||||
ocv_target_link_libraries(opencv_highgui_gtk3 ocv.3rdparty.gtkglext)
|
||||
endif()
|
||||
endif()
|
||||
if(TARGET ocv.3rdparty.gtk2 AND ("gtk2" IN_LIST HIGHGUI_PLUGIN_LIST OR HIGHGUI_PLUGIN_LIST STREQUAL "all"))
|
||||
ocv_create_builtin_highgui_plugin(opencv_highgui_gtk2 ocv.3rdparty.gtk2 "window_gtk.cpp")
|
||||
if(TARGET ocv.3rdparty.gthread)
|
||||
ocv_target_link_libraries(opencv_highgui_gtk2 ocv.3rdparty.gthread)
|
||||
endif()
|
||||
if(TARGET ocv.3rdparty.gtkglext)
|
||||
ocv_target_link_libraries(opencv_highgui_gtk2 ocv.3rdparty.gtkglext)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_HIGHGUI_BUILTIN_BACKEND)
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "NONE")
|
||||
endif()
|
||||
message(STATUS "highgui: using builtin backend: ${OPENCV_HIGHGUI_BUILTIN_BACKEND}")
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "${OPENCV_HIGHGUI_BUILTIN_BACKEND}" PARENT_SCOPE) # informational
|
||||
|
||||
if(TRUE)
|
||||
# these variables are set by 'ocv_append_build_options(HIGHGUI ...)'
|
||||
foreach(P ${HIGHGUI_INCLUDE_DIRS})
|
||||
ocv_include_directories(${P})
|
||||
endforeach()
|
||||
|
||||
foreach(P ${HIGHGUI_LIBRARY_DIRS})
|
||||
link_directories(${P})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(tgts STREQUAL "PRIVATE")
|
||||
set(tgts "")
|
||||
endif()
|
||||
|
||||
# install used dependencies only
|
||||
if(NOT BUILD_SHARED_LIBS
|
||||
AND NOT (CMAKE_VERSION VERSION_LESS "3.13.0") # upgrade CMake: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2152
|
||||
)
|
||||
foreach(tgt in ${tgts})
|
||||
if(tgt MATCHES "^ocv\.3rdparty\.")
|
||||
install(TARGETS ${tgt} EXPORT OpenCVModules)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
source_group("Src" FILES ${highgui_srcs} ${highgui_hdrs})
|
||||
source_group("Include" FILES ${highgui_ext_hdrs})
|
||||
ocv_set_module_sources(HEADERS ${highgui_ext_hdrs} SOURCES ${highgui_srcs} ${highgui_hdrs})
|
||||
ocv_module_include_directories()
|
||||
|
||||
ocv_create_module(${HIGHGUI_LIBRARIES})
|
||||
|
||||
macro(ocv_highgui_configure_target)
|
||||
if(APPLE)
|
||||
add_apple_compiler_options(${the_module})
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
|
||||
endif()
|
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
|
||||
endmacro()
|
||||
|
||||
if(NOT BUILD_opencv_world)
|
||||
ocv_highgui_configure_target()
|
||||
endif()
|
||||
|
||||
ocv_add_accuracy_tests(${tgts})
|
||||
#ocv_add_perf_tests(${tgts})
|
||||
|
||||
if(HIGHGUI_ENABLE_PLUGINS)
|
||||
ocv_target_compile_definitions(${the_module} PRIVATE ENABLE_PLUGINS)
|
||||
if(TARGET opencv_test_highgui)
|
||||
ocv_target_compile_definitions(opencv_test_highgui PRIVATE ENABLE_PLUGINS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${tgts})
|
||||
|
||||
# generate module configuration
|
||||
set(CONFIG_STR "// Auto-generated file
|
||||
#define OPENCV_HIGHGUI_BUILTIN_BACKEND_STR \"${OPENCV_HIGHGUI_BUILTIN_BACKEND}\"
|
||||
")
|
||||
if(OPENCV_HIGHGUI_BUILTIN_BACKEND STREQUAL "NONE")
|
||||
set(CONFIG_STR "${CONFIG_STR}
|
||||
#define OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND 1
|
||||
")
|
||||
endif()
|
||||
|
||||
ocv_update_file("${CMAKE_CURRENT_BINARY_DIR}/opencv_highgui_config.hpp" "${CONFIG_STR}")
|
45
3rdparty/opencv-4.5.4/modules/highgui/cmake/detect_gtk.cmake
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
# --- GTK ---
|
||||
ocv_clear_vars(HAVE_GTK HAVE_GTK2 HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
|
||||
if(WITH_GTK)
|
||||
if(NOT WITH_GTK_2_X)
|
||||
ocv_check_modules(GTK3 gtk+-3.0)
|
||||
if(HAVE_GTK3)
|
||||
ocv_add_external_target(gtk3 "${GTK3_INCLUDE_DIRS}" "${GTK3_LIBRARIES}" "HAVE_GTK3;HAVE_GTK")
|
||||
set(HAVE_GTK TRUE)
|
||||
endif()
|
||||
endif()
|
||||
if((PROJECT_NAME STREQUAL "OpenCV" AND HIGHGUI_ENABLE_PLUGINS) OR NOT HAVE_GTK3)
|
||||
ocv_check_modules(GTK2 gtk+-2.0)
|
||||
if(HAVE_GTK2)
|
||||
set(MIN_VER_GTK "2.18.0")
|
||||
if(GTK2_VERSION VERSION_LESS MIN_VER_GTK)
|
||||
message(FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${GTK2_VERSION} found)")
|
||||
else()
|
||||
ocv_add_external_target(gtk2 "${GTK2_INCLUDE_DIRS}" "${GTK2_LIBRARIES}" "HAVE_GTK2;HAVE_GTK")
|
||||
set(HAVE_GTK TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
ocv_check_modules(GTHREAD gthread-2.0)
|
||||
if(HAVE_GTK AND NOT HAVE_GTHREAD)
|
||||
message(FATAL_ERROR "gthread not found. This library is required when building with GTK support")
|
||||
else()
|
||||
ocv_add_external_target(gthread "${GTHREAD_INCLUDE_DIRS}" "${GTHREAD_LIBRARIES}" "HAVE_GTHREAD")
|
||||
endif()
|
||||
if((WITH_OPENGL OR HAVE_OPENGL) AND HAVE_GTK2)
|
||||
ocv_check_modules(GTKGLEXT gtkglext-1.0)
|
||||
if(HAVE_GTKGLEXT)
|
||||
ocv_add_external_target(gtkglext "${GTKGLEXT_INCLUDE_DIRS}" "${GTKGLEXT_LIBRARIES}" "HAVE_GTKGLEXT")
|
||||
endif()
|
||||
endif()
|
||||
elseif(HAVE_GTK)
|
||||
ocv_add_external_target(gtk "${GTK_INCLUDE_DIRS}" "${GTK_LIBRARIES}" "${GTK_DEFINES};HAVE_GTK")
|
||||
endif()
|
||||
|
||||
if(WITH_OPENGL AND HAVE_GTKGLEXT)
|
||||
find_package(OpenGL QUIET)
|
||||
if(OPENGL_FOUND)
|
||||
set(HAVE_OPENGL TRUE)
|
||||
ocv_add_external_target(gtk_opengl "${OPENGL_INCLUDE_DIRS}" "${OPENGL_LIBRARIES}" "HAVE_OPENGL")
|
||||
endif()
|
||||
endif()
|
15
3rdparty/opencv-4.5.4/modules/highgui/cmake/detect_win32ui.cmake
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#--- Win32 UI ---
|
||||
ocv_clear_vars(HAVE_WIN32UI)
|
||||
if(WITH_WIN32UI)
|
||||
try_compile(HAVE_WIN32UI
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/win32uitest.cpp"
|
||||
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=user32;gdi32")
|
||||
if(HAVE_WIN32UI)
|
||||
set(__libs "user32" "gdi32")
|
||||
if(OpenCV_ARCH STREQUAL "ARM64")
|
||||
list(APPEND __libs "comdlg32" "advapi32")
|
||||
endif()
|
||||
ocv_add_external_target(win32ui "" "${__libs}" "HAVE_WIN32UI")
|
||||
endif()
|
||||
endif()
|
44
3rdparty/opencv-4.5.4/modules/highgui/cmake/init.cmake
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
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
|
||||
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)
|
||||
# TODO cocoa
|
||||
# TODO qt
|
||||
# TODO opengl
|
||||
|
||||
# FIXIT: move content of cmake/OpenCVFindLibsGUI.cmake here (need to resolve CMake scope issues)
|
61
3rdparty/opencv-4.5.4/modules/highgui/cmake/plugin.cmake
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
function(ocv_create_builtin_highgui_plugin name target)
|
||||
|
||||
ocv_debug_message("ocv_create_builtin_highgui_plugin(${ARGV})")
|
||||
|
||||
if(NOT TARGET ${target})
|
||||
message(FATAL_ERROR "${target} does not exist!")
|
||||
endif()
|
||||
if(NOT OpenCV_SOURCE_DIR)
|
||||
message(FATAL_ERROR "OpenCV_SOURCE_DIR must be set to build the plugin!")
|
||||
endif()
|
||||
|
||||
message(STATUS "HighGUI: add builtin plugin '${name}'")
|
||||
|
||||
foreach(src ${ARGN})
|
||||
list(APPEND sources "${CMAKE_CURRENT_LIST_DIR}/src/${src}")
|
||||
endforeach()
|
||||
|
||||
add_library(${name} MODULE ${sources})
|
||||
target_include_directories(${name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
target_compile_definitions(${name} PRIVATE BUILD_PLUGIN)
|
||||
target_link_libraries(${name} PRIVATE ${target})
|
||||
|
||||
foreach(mod opencv_highgui
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_imgcodecs
|
||||
opencv_videoio # TODO remove this dependency
|
||||
)
|
||||
ocv_target_link_libraries(${name} LINK_PRIVATE ${mod})
|
||||
ocv_target_include_directories(${name} "${OPENCV_MODULE_${mod}_LOCATION}/include")
|
||||
endforeach()
|
||||
|
||||
if(WIN32)
|
||||
set(OPENCV_PLUGIN_VERSION "${OPENCV_DLLVERSION}" CACHE STRING "")
|
||||
if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(OPENCV_PLUGIN_ARCH "_64" CACHE STRING "")
|
||||
else()
|
||||
set(OPENCV_PLUGIN_ARCH "" CACHE STRING "")
|
||||
endif()
|
||||
else()
|
||||
set(OPENCV_PLUGIN_VERSION "" CACHE STRING "")
|
||||
set(OPENCV_PLUGIN_ARCH "" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
set_target_properties(${name} PROPERTIES
|
||||
CXX_STANDARD 11
|
||||
CXX_VISIBILITY_PRESET hidden
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
OUTPUT_NAME "${name}${OPENCV_PLUGIN_VERSION}${OPENCV_PLUGIN_ARCH}"
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
|
||||
install(TARGETS ${name} OPTIONAL LIBRARY DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT plugins)
|
||||
else()
|
||||
install(TARGETS ${name} OPTIONAL LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT plugins)
|
||||
endif()
|
||||
|
||||
add_dependencies(opencv_highgui_plugins ${name})
|
||||
|
||||
endfunction()
|
BIN
3rdparty/opencv-4.5.4/modules/highgui/doc/pics/qtgui.png
vendored
Normal file
After Width: | Height: | Size: 371 KiB |
868
3rdparty/opencv-4.5.4/modules/highgui/include/opencv2/highgui.hpp
vendored
Normal file
@ -0,0 +1,868 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_HIGHGUI_HPP
|
||||
#define OPENCV_HIGHGUI_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#ifdef HAVE_OPENCV_IMGCODECS
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_OPENCV_VIDEOIO
|
||||
#include "opencv2/videoio.hpp"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup highgui High-level GUI
|
||||
|
||||
While OpenCV was designed for use in full-scale applications and can be used within functionally
|
||||
rich UI frameworks (such as Qt\*, WinForms\*, or Cocoa\*) or without any UI at all, sometimes there
|
||||
it is required to try functionality quickly and visualize the results. This is what the HighGUI
|
||||
module has been designed for.
|
||||
|
||||
It provides easy interface to:
|
||||
|
||||
- Create and manipulate windows that can display images and "remember" their content (no need to
|
||||
handle repaint events from OS).
|
||||
- Add trackbars to the windows, handle simple mouse events as well as keyboard commands.
|
||||
|
||||
@{
|
||||
@defgroup highgui_window_flags Flags related creating and manipulating HighGUI windows and mouse events
|
||||
@defgroup highgui_opengl OpenGL support
|
||||
@defgroup highgui_qt Qt New Functions
|
||||
|
||||

|
||||
|
||||
This figure explains new functionality implemented with Qt\* GUI. The new GUI provides a statusbar,
|
||||
a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it.
|
||||
If you cannot see the control panel, press Ctrl+P or right-click any Qt window and select **Display
|
||||
properties window**.
|
||||
|
||||
- To attach a trackbar, the window name parameter must be NULL.
|
||||
|
||||
- To attach a buttonbar, a button must be created. If the last bar attached to the control panel
|
||||
is a buttonbar, the new button is added to the right of the last button. If the last bar
|
||||
attached to the control panel is a trackbar, or the control panel is empty, a new buttonbar is
|
||||
created. Then, a new button is attached to it.
|
||||
|
||||
See below the example used to generate the figure:
|
||||
@code
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int value = 50;
|
||||
int value2 = 0;
|
||||
|
||||
|
||||
namedWindow("main1",WINDOW_NORMAL);
|
||||
namedWindow("main2",WINDOW_AUTOSIZE | WINDOW_GUI_NORMAL);
|
||||
createTrackbar( "track1", "main1", &value, 255, NULL);
|
||||
|
||||
String nameb1 = "button1";
|
||||
String nameb2 = "button2";
|
||||
|
||||
createButton(nameb1,callbackButton,&nameb1,QT_CHECKBOX,1);
|
||||
createButton(nameb2,callbackButton,NULL,QT_CHECKBOX,0);
|
||||
createTrackbar( "track2", NULL, &value2, 255, NULL);
|
||||
createButton("button5",callbackButton1,NULL,QT_RADIOBOX,0);
|
||||
createButton("button6",callbackButton2,NULL,QT_RADIOBOX,1);
|
||||
|
||||
setMouseCallback( "main2",on_mouse,NULL );
|
||||
|
||||
Mat img1 = imread("files/flower.jpg");
|
||||
VideoCapture video;
|
||||
video.open("files/hockey.avi");
|
||||
|
||||
Mat img2,img3;
|
||||
|
||||
while( waitKey(33) != 27 )
|
||||
{
|
||||
img1.convertTo(img2,-1,1,value);
|
||||
video >> img3;
|
||||
|
||||
imshow("main1",img2);
|
||||
imshow("main2",img3);
|
||||
}
|
||||
|
||||
destroyAllWindows();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@endcode
|
||||
|
||||
|
||||
@defgroup highgui_winrt WinRT support
|
||||
|
||||
This figure explains new functionality implemented with WinRT GUI. The new GUI provides an Image control,
|
||||
and a slider panel. Slider panel holds trackbars attached to it.
|
||||
|
||||
Sliders are attached below the image control. Every new slider is added below the previous one.
|
||||
|
||||
See below the example used to generate the figure:
|
||||
@code
|
||||
void sample_app::MainPage::ShowWindow()
|
||||
{
|
||||
static cv::String windowName("sample");
|
||||
cv::winrt_initContainer(this->cvContainer);
|
||||
cv::namedWindow(windowName); // not required
|
||||
|
||||
cv::Mat image = cv::imread("Assets/sample.jpg");
|
||||
cv::Mat converted = cv::Mat(image.rows, image.cols, CV_8UC4);
|
||||
cv::cvtColor(image, converted, COLOR_BGR2BGRA);
|
||||
cv::imshow(windowName, converted); // this will create window if it hasn't been created before
|
||||
|
||||
int state = 42;
|
||||
cv::TrackbarCallback callback = [](int pos, void* userdata)
|
||||
{
|
||||
if (pos == 0) {
|
||||
cv::destroyWindow(windowName);
|
||||
}
|
||||
};
|
||||
cv::TrackbarCallback callbackTwin = [](int pos, void* userdata)
|
||||
{
|
||||
if (pos >= 70) {
|
||||
cv::destroyAllWindows();
|
||||
}
|
||||
};
|
||||
cv::createTrackbar("Sample trackbar", windowName, &state, 100, callback);
|
||||
cv::createTrackbar("Twin brother", windowName, &state, 100, callbackTwin);
|
||||
}
|
||||
@endcode
|
||||
|
||||
@defgroup highgui_c C API
|
||||
@}
|
||||
*/
|
||||
|
||||
///////////////////////// graphical user interface //////////////////////////
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup highgui
|
||||
//! @{
|
||||
|
||||
//! @addtogroup highgui_window_flags
|
||||
//! @{
|
||||
|
||||
//! Flags for cv::namedWindow
|
||||
enum WindowFlags {
|
||||
WINDOW_NORMAL = 0x00000000, //!< the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size.
|
||||
WINDOW_AUTOSIZE = 0x00000001, //!< the user cannot resize the window, the size is constrainted by the image displayed.
|
||||
WINDOW_OPENGL = 0x00001000, //!< window with opengl support.
|
||||
|
||||
WINDOW_FULLSCREEN = 1, //!< change the window to fullscreen.
|
||||
WINDOW_FREERATIO = 0x00000100, //!< the image expends as much as it can (no ratio constraint).
|
||||
WINDOW_KEEPRATIO = 0x00000000, //!< the ratio of the image is respected.
|
||||
WINDOW_GUI_EXPANDED=0x00000000, //!< status bar and tool bar
|
||||
WINDOW_GUI_NORMAL = 0x00000010, //!< old fashious way
|
||||
};
|
||||
|
||||
//! Flags for cv::setWindowProperty / cv::getWindowProperty
|
||||
enum WindowPropertyFlags {
|
||||
WND_PROP_FULLSCREEN = 0, //!< fullscreen property (can be WINDOW_NORMAL or WINDOW_FULLSCREEN).
|
||||
WND_PROP_AUTOSIZE = 1, //!< autosize property (can be WINDOW_NORMAL or WINDOW_AUTOSIZE).
|
||||
WND_PROP_ASPECT_RATIO = 2, //!< window's aspect ration (can be set to WINDOW_FREERATIO or WINDOW_KEEPRATIO).
|
||||
WND_PROP_OPENGL = 3, //!< opengl support.
|
||||
WND_PROP_VISIBLE = 4, //!< checks whether the window exists and is visible
|
||||
WND_PROP_TOPMOST = 5, //!< property to toggle normal window being topmost or not
|
||||
WND_PROP_VSYNC = 6 //!< enable or disable VSYNC (in OpenGL mode)
|
||||
};
|
||||
|
||||
//! Mouse Events see cv::MouseCallback
|
||||
enum MouseEventTypes {
|
||||
EVENT_MOUSEMOVE = 0, //!< indicates that the mouse pointer has moved over the window.
|
||||
EVENT_LBUTTONDOWN = 1, //!< indicates that the left mouse button is pressed.
|
||||
EVENT_RBUTTONDOWN = 2, //!< indicates that the right mouse button is pressed.
|
||||
EVENT_MBUTTONDOWN = 3, //!< indicates that the middle mouse button is pressed.
|
||||
EVENT_LBUTTONUP = 4, //!< indicates that left mouse button is released.
|
||||
EVENT_RBUTTONUP = 5, //!< indicates that right mouse button is released.
|
||||
EVENT_MBUTTONUP = 6, //!< indicates that middle mouse button is released.
|
||||
EVENT_LBUTTONDBLCLK = 7, //!< indicates that left mouse button is double clicked.
|
||||
EVENT_RBUTTONDBLCLK = 8, //!< indicates that right mouse button is double clicked.
|
||||
EVENT_MBUTTONDBLCLK = 9, //!< indicates that middle mouse button is double clicked.
|
||||
EVENT_MOUSEWHEEL = 10,//!< positive and negative values mean forward and backward scrolling, respectively.
|
||||
EVENT_MOUSEHWHEEL = 11 //!< positive and negative values mean right and left scrolling, respectively.
|
||||
};
|
||||
|
||||
//! Mouse Event Flags see cv::MouseCallback
|
||||
enum MouseEventFlags {
|
||||
EVENT_FLAG_LBUTTON = 1, //!< indicates that the left mouse button is down.
|
||||
EVENT_FLAG_RBUTTON = 2, //!< indicates that the right mouse button is down.
|
||||
EVENT_FLAG_MBUTTON = 4, //!< indicates that the middle mouse button is down.
|
||||
EVENT_FLAG_CTRLKEY = 8, //!< indicates that CTRL Key is pressed.
|
||||
EVENT_FLAG_SHIFTKEY = 16,//!< indicates that SHIFT Key is pressed.
|
||||
EVENT_FLAG_ALTKEY = 32 //!< indicates that ALT Key is pressed.
|
||||
};
|
||||
|
||||
//! @} highgui_window_flags
|
||||
|
||||
//! @addtogroup highgui_qt
|
||||
//! @{
|
||||
|
||||
//! Qt font weight
|
||||
enum QtFontWeights {
|
||||
QT_FONT_LIGHT = 25, //!< Weight of 25
|
||||
QT_FONT_NORMAL = 50, //!< Weight of 50
|
||||
QT_FONT_DEMIBOLD = 63, //!< Weight of 63
|
||||
QT_FONT_BOLD = 75, //!< Weight of 75
|
||||
QT_FONT_BLACK = 87 //!< Weight of 87
|
||||
};
|
||||
|
||||
//! Qt font style
|
||||
enum QtFontStyles {
|
||||
QT_STYLE_NORMAL = 0, //!< Normal font.
|
||||
QT_STYLE_ITALIC = 1, //!< Italic font.
|
||||
QT_STYLE_OBLIQUE = 2 //!< Oblique font.
|
||||
};
|
||||
|
||||
//! Qt "button" type
|
||||
enum QtButtonTypes {
|
||||
QT_PUSH_BUTTON = 0, //!< Push button.
|
||||
QT_CHECKBOX = 1, //!< Checkbox button.
|
||||
QT_RADIOBOX = 2, //!< Radiobox button.
|
||||
QT_NEW_BUTTONBAR = 1024 //!< Button should create a new buttonbar
|
||||
};
|
||||
|
||||
//! @} highgui_qt
|
||||
|
||||
/** @brief Callback function for mouse events. see cv::setMouseCallback
|
||||
@param event one of the cv::MouseEventTypes constants.
|
||||
@param x The x-coordinate of the mouse event.
|
||||
@param y The y-coordinate of the mouse event.
|
||||
@param flags one of the cv::MouseEventFlags constants.
|
||||
@param userdata The optional parameter.
|
||||
*/
|
||||
typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata);
|
||||
|
||||
/** @brief Callback function for Trackbar see cv::createTrackbar
|
||||
@param pos current position of the specified trackbar.
|
||||
@param userdata The optional parameter.
|
||||
*/
|
||||
typedef void (*TrackbarCallback)(int pos, void* userdata);
|
||||
|
||||
/** @brief Callback function defined to be called every frame. See cv::setOpenGlDrawCallback
|
||||
@param userdata The optional parameter.
|
||||
*/
|
||||
typedef void (*OpenGlDrawCallback)(void* userdata);
|
||||
|
||||
/** @brief Callback function for a button created by cv::createButton
|
||||
@param state current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
|
||||
@param userdata The optional parameter.
|
||||
*/
|
||||
typedef void (*ButtonCallback)(int state, void* userdata);
|
||||
|
||||
/** @brief Creates a window.
|
||||
|
||||
The function namedWindow creates a window that can be used as a placeholder for images and
|
||||
trackbars. Created windows are referred to by their names.
|
||||
|
||||
If a window with the same name already exists, the function does nothing.
|
||||
|
||||
You can call cv::destroyWindow or cv::destroyAllWindows to close the window and de-allocate any associated
|
||||
memory usage. For a simple program, you do not really have to call these functions because all the
|
||||
resources and windows of the application are closed automatically by the operating system upon exit.
|
||||
|
||||
@note
|
||||
|
||||
Qt backend supports additional flags:
|
||||
- **WINDOW_NORMAL or WINDOW_AUTOSIZE:** WINDOW_NORMAL enables you to resize the
|
||||
window, whereas WINDOW_AUTOSIZE adjusts automatically the window size to fit the
|
||||
displayed image (see imshow ), and you cannot change the window size manually.
|
||||
- **WINDOW_FREERATIO or WINDOW_KEEPRATIO:** WINDOW_FREERATIO adjusts the image
|
||||
with no respect to its ratio, whereas WINDOW_KEEPRATIO keeps the image ratio.
|
||||
- **WINDOW_GUI_NORMAL or WINDOW_GUI_EXPANDED:** WINDOW_GUI_NORMAL is the old way to draw the window
|
||||
without statusbar and toolbar, whereas WINDOW_GUI_EXPANDED is a new enhanced GUI.
|
||||
By default, flags == WINDOW_AUTOSIZE | WINDOW_KEEPRATIO | WINDOW_GUI_EXPANDED
|
||||
|
||||
@param winname Name of the window in the window caption that may be used as a window identifier.
|
||||
@param flags Flags of the window. The supported flags are: (cv::WindowFlags)
|
||||
*/
|
||||
CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE);
|
||||
|
||||
/** @brief Destroys the specified window.
|
||||
|
||||
The function destroyWindow destroys the window with the given name.
|
||||
|
||||
@param winname Name of the window to be destroyed.
|
||||
*/
|
||||
CV_EXPORTS_W void destroyWindow(const String& winname);
|
||||
|
||||
/** @brief Destroys all of the HighGUI windows.
|
||||
|
||||
The function destroyAllWindows destroys all of the opened HighGUI windows.
|
||||
*/
|
||||
CV_EXPORTS_W void destroyAllWindows();
|
||||
|
||||
CV_EXPORTS_W int startWindowThread();
|
||||
|
||||
/** @brief Similar to #waitKey, but returns full key code.
|
||||
|
||||
@note
|
||||
|
||||
Key code is implementation specific and depends on used backend: QT/GTK/Win32/etc
|
||||
|
||||
*/
|
||||
CV_EXPORTS_W int waitKeyEx(int delay = 0);
|
||||
|
||||
/** @brief Waits for a pressed key.
|
||||
|
||||
The function waitKey waits for a key event infinitely (when \f$\texttt{delay}\leq 0\f$ ) or for delay
|
||||
milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the
|
||||
function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is
|
||||
running on your computer at that time. It returns the code of the pressed key or -1 if no key was
|
||||
pressed before the specified time had elapsed. To check for a key press but not wait for it, use
|
||||
#pollKey.
|
||||
|
||||
@note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle
|
||||
GUI events, so one of them needs to be called periodically for normal event processing unless
|
||||
HighGUI is used within an environment that takes care of event processing.
|
||||
|
||||
@note The function only works if there is at least one HighGUI window created and the window is
|
||||
active. If there are several HighGUI windows, any of them can be active.
|
||||
|
||||
@param delay Delay in milliseconds. 0 is the special value that means "forever".
|
||||
*/
|
||||
CV_EXPORTS_W int waitKey(int delay = 0);
|
||||
|
||||
/** @brief Polls for a pressed key.
|
||||
|
||||
The function pollKey polls for a key event without waiting. It returns the code of the pressed key
|
||||
or -1 if no key was pressed since the last invocation. To wait until a key was pressed, use #waitKey.
|
||||
|
||||
@note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle
|
||||
GUI events, so one of them needs to be called periodically for normal event processing unless
|
||||
HighGUI is used within an environment that takes care of event processing.
|
||||
|
||||
@note The function only works if there is at least one HighGUI window created and the window is
|
||||
active. If there are several HighGUI windows, any of them can be active.
|
||||
*/
|
||||
CV_EXPORTS_W int pollKey();
|
||||
|
||||
/** @brief Displays an image in the specified window.
|
||||
|
||||
The function imshow displays an image in the specified window. If the window was created with the
|
||||
cv::WINDOW_AUTOSIZE flag, the image is shown with its original size, however it is still limited by the screen resolution.
|
||||
Otherwise, the image is scaled to fit the window. The function may scale the image, depending on its depth:
|
||||
|
||||
- If the image is 8-bit unsigned, it is displayed as is.
|
||||
- If the image is 16-bit unsigned, the pixels are divided by 256. That is, the
|
||||
value range [0,255\*256] is mapped to [0,255].
|
||||
- If the image is 32-bit or 64-bit floating-point, the pixel values are multiplied by 255. That is, the
|
||||
value range [0,1] is mapped to [0,255].
|
||||
- 32-bit integer images are not processed anymore due to ambiguouty of required transform.
|
||||
Convert to 8-bit unsigned matrix using a custom preprocessing specific to image's context.
|
||||
|
||||
If window was created with OpenGL support, cv::imshow also support ogl::Buffer , ogl::Texture2D and
|
||||
cuda::GpuMat as input.
|
||||
|
||||
If the window was not created before this function, it is assumed creating a window with cv::WINDOW_AUTOSIZE.
|
||||
|
||||
If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow.
|
||||
|
||||
@note This function should be followed by a call to cv::waitKey or cv::pollKey to perform GUI
|
||||
housekeeping tasks that are necessary to actually show the given image and make the window respond
|
||||
to mouse and keyboard events. Otherwise, it won't display the image and the window might lock up.
|
||||
For example, **waitKey(0)** will display the window infinitely until any keypress (it is suitable
|
||||
for image display). **waitKey(25)** will display a frame and wait approximately 25 ms for a key
|
||||
press (suitable for displaying a video frame-by-frame). To remove the window, use cv::destroyWindow.
|
||||
|
||||
@note
|
||||
|
||||
[__Windows Backend Only__] Pressing Ctrl+C will copy the image to the clipboard.
|
||||
|
||||
[__Windows Backend Only__] Pressing Ctrl+S will show a dialog to save the image.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param mat Image to be shown.
|
||||
*/
|
||||
CV_EXPORTS_W void imshow(const String& winname, InputArray mat);
|
||||
|
||||
/** @brief Resizes the window to the specified size
|
||||
|
||||
@note
|
||||
|
||||
- The specified window size is for the image area. Toolbars are not counted.
|
||||
- Only windows created without cv::WINDOW_AUTOSIZE flag can be resized.
|
||||
|
||||
@param winname Window name.
|
||||
@param width The new window width.
|
||||
@param height The new window height.
|
||||
*/
|
||||
CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height);
|
||||
|
||||
/** @overload
|
||||
@param winname Window name.
|
||||
@param size The new window size.
|
||||
*/
|
||||
CV_EXPORTS_W void resizeWindow(const String& winname, const cv::Size& size);
|
||||
|
||||
/** @brief Moves the window to the specified position
|
||||
|
||||
@param winname Name of the window.
|
||||
@param x The new x-coordinate of the window.
|
||||
@param y The new y-coordinate of the window.
|
||||
*/
|
||||
CV_EXPORTS_W void moveWindow(const String& winname, int x, int y);
|
||||
|
||||
/** @brief Changes parameters of a window dynamically.
|
||||
|
||||
The function setWindowProperty enables changing properties of a window.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param prop_id Window property to edit. The supported operation flags are: (cv::WindowPropertyFlags)
|
||||
@param prop_value New value of the window property. The supported flags are: (cv::WindowFlags)
|
||||
*/
|
||||
CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value);
|
||||
|
||||
/** @brief Updates window title
|
||||
@param winname Name of the window.
|
||||
@param title New title.
|
||||
*/
|
||||
CV_EXPORTS_W void setWindowTitle(const String& winname, const String& title);
|
||||
|
||||
/** @brief Provides parameters of a window.
|
||||
|
||||
The function getWindowProperty returns properties of a window.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param prop_id Window property to retrieve. The following operation flags are available: (cv::WindowPropertyFlags)
|
||||
|
||||
@sa setWindowProperty
|
||||
*/
|
||||
CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id);
|
||||
|
||||
/** @brief Provides rectangle of image in the window.
|
||||
|
||||
The function getWindowImageRect returns the client screen coordinates, width and height of the image rendering area.
|
||||
|
||||
@param winname Name of the window.
|
||||
|
||||
@sa resizeWindow moveWindow
|
||||
*/
|
||||
CV_EXPORTS_W Rect getWindowImageRect(const String& winname);
|
||||
|
||||
/** @example samples/cpp/create_mask.cpp
|
||||
This program demonstrates using mouse events and how to make and use a mask image (black and white) .
|
||||
*/
|
||||
/** @brief Sets mouse handler for the specified window
|
||||
|
||||
@param winname Name of the window.
|
||||
@param onMouse Callback function for mouse events. See OpenCV samples on how to specify and use the callback.
|
||||
@param userdata The optional parameter passed to the callback.
|
||||
*/
|
||||
CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0);
|
||||
|
||||
/** @brief Gets the mouse-wheel motion delta, when handling mouse-wheel events cv::EVENT_MOUSEWHEEL and
|
||||
cv::EVENT_MOUSEHWHEEL.
|
||||
|
||||
For regular mice with a scroll-wheel, delta will be a multiple of 120. The value 120 corresponds to
|
||||
a one notch rotation of the wheel or the threshold for action to be taken and one such action should
|
||||
occur for each delta. Some high-precision mice with higher-resolution freely-rotating wheels may
|
||||
generate smaller values.
|
||||
|
||||
For cv::EVENT_MOUSEWHEEL positive and negative values mean forward and backward scrolling,
|
||||
respectively. For cv::EVENT_MOUSEHWHEEL, where available, positive and negative values mean right and
|
||||
left scrolling, respectively.
|
||||
|
||||
@note
|
||||
|
||||
Mouse-wheel events are currently supported only on Windows.
|
||||
|
||||
@param flags The mouse callback flags parameter.
|
||||
*/
|
||||
CV_EXPORTS int getMouseWheelDelta(int flags);
|
||||
|
||||
/** @brief Allows users to select a ROI on the given image.
|
||||
|
||||
The function creates a window and allows users to select a ROI using the mouse.
|
||||
Controls: use `space` or `enter` to finish selection, use key `c` to cancel selection (function will return the zero cv::Rect).
|
||||
|
||||
@param windowName name of the window where selection process will be shown.
|
||||
@param img image to select a ROI.
|
||||
@param showCrosshair if true crosshair of selection rectangle will be shown.
|
||||
@param fromCenter if true center of selection will match initial mouse position. In opposite case a corner of
|
||||
selection rectangle will correspont to the initial mouse position.
|
||||
@return selected ROI or empty rect if selection canceled.
|
||||
|
||||
@note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...).
|
||||
After finish of work an empty callback will be set for the used window.
|
||||
*/
|
||||
CV_EXPORTS_W Rect selectROI(const String& windowName, InputArray img, bool showCrosshair = true, bool fromCenter = false);
|
||||
|
||||
/** @overload
|
||||
*/
|
||||
CV_EXPORTS_W Rect selectROI(InputArray img, bool showCrosshair = true, bool fromCenter = false);
|
||||
|
||||
/** @brief Allows users to select multiple ROIs on the given image.
|
||||
|
||||
The function creates a window and allows users to select multiple ROIs using the mouse.
|
||||
Controls: use `space` or `enter` to finish current selection and start a new one,
|
||||
use `esc` to terminate multiple ROI selection process.
|
||||
|
||||
@param windowName name of the window where selection process will be shown.
|
||||
@param img image to select a ROI.
|
||||
@param boundingBoxes selected ROIs.
|
||||
@param showCrosshair if true crosshair of selection rectangle will be shown.
|
||||
@param fromCenter if true center of selection will match initial mouse position. In opposite case a corner of
|
||||
selection rectangle will correspont to the initial mouse position.
|
||||
|
||||
@note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...).
|
||||
After finish of work an empty callback will be set for the used window.
|
||||
*/
|
||||
CV_EXPORTS_W void selectROIs(const String& windowName, InputArray img,
|
||||
CV_OUT std::vector<Rect>& boundingBoxes, bool showCrosshair = true, bool fromCenter = false);
|
||||
|
||||
/** @brief Creates a trackbar and attaches it to the specified window.
|
||||
|
||||
The function createTrackbar creates a trackbar (a slider or range control) with the specified name
|
||||
and range, assigns a variable value to be a position synchronized with the trackbar and specifies
|
||||
the callback function onChange to be called on the trackbar position change. The created trackbar is
|
||||
displayed in the specified window winname.
|
||||
|
||||
@note
|
||||
|
||||
[__Qt Backend Only__] winname can be empty if the trackbar should be attached to the
|
||||
control panel.
|
||||
|
||||
Clicking the label of each trackbar enables editing the trackbar values manually.
|
||||
|
||||
@param trackbarname Name of the created trackbar.
|
||||
@param winname Name of the window that will be used as a parent of the created trackbar.
|
||||
@param value Optional pointer to an integer variable whose value reflects the position of the
|
||||
slider. Upon creation, the slider position is defined by this variable.
|
||||
@param count Maximal position of the slider. The minimal position is always 0.
|
||||
@param onChange Pointer to the function to be called every time the slider changes position. This
|
||||
function should be prototyped as void Foo(int,void\*); , where the first parameter is the trackbar
|
||||
position and the second parameter is the user data (see the next parameter). If the callback is
|
||||
the NULL pointer, no callbacks are called, but only value is updated.
|
||||
@param userdata User data that is passed as is to the callback. It can be used to handle trackbar
|
||||
events without using global variables.
|
||||
*/
|
||||
CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname,
|
||||
int* value, int count,
|
||||
TrackbarCallback onChange = 0,
|
||||
void* userdata = 0);
|
||||
|
||||
/** @brief Returns the trackbar position.
|
||||
|
||||
The function returns the current position of the specified trackbar.
|
||||
|
||||
@note
|
||||
|
||||
[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control
|
||||
panel.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of the trackbar.
|
||||
*/
|
||||
CV_EXPORTS_W int getTrackbarPos(const String& trackbarname, const String& winname);
|
||||
|
||||
/** @brief Sets the trackbar position.
|
||||
|
||||
The function sets the position of the specified trackbar in the specified window.
|
||||
|
||||
@note
|
||||
|
||||
[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control
|
||||
panel.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of trackbar.
|
||||
@param pos New position.
|
||||
*/
|
||||
CV_EXPORTS_W void setTrackbarPos(const String& trackbarname, const String& winname, int pos);
|
||||
|
||||
/** @brief Sets the trackbar maximum position.
|
||||
|
||||
The function sets the maximum position of the specified trackbar in the specified window.
|
||||
|
||||
@note
|
||||
|
||||
[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control
|
||||
panel.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of trackbar.
|
||||
@param maxval New maximum position.
|
||||
*/
|
||||
CV_EXPORTS_W void setTrackbarMax(const String& trackbarname, const String& winname, int maxval);
|
||||
|
||||
/** @brief Sets the trackbar minimum position.
|
||||
|
||||
The function sets the minimum position of the specified trackbar in the specified window.
|
||||
|
||||
@note
|
||||
|
||||
[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control
|
||||
panel.
|
||||
|
||||
@param trackbarname Name of the trackbar.
|
||||
@param winname Name of the window that is the parent of trackbar.
|
||||
@param minval New minimum position.
|
||||
*/
|
||||
CV_EXPORTS_W void setTrackbarMin(const String& trackbarname, const String& winname, int minval);
|
||||
|
||||
//! @addtogroup highgui_opengl OpenGL support
|
||||
//! @{
|
||||
|
||||
/** @brief Displays OpenGL 2D texture in the specified window.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param tex OpenGL 2D texture data.
|
||||
*/
|
||||
CV_EXPORTS void imshow(const String& winname, const ogl::Texture2D& tex);
|
||||
|
||||
/** @brief Sets a callback function to be called to draw on top of displayed image.
|
||||
|
||||
The function setOpenGlDrawCallback can be used to draw 3D data on the window. See the example of
|
||||
callback function below:
|
||||
@code
|
||||
void on_opengl(void* param)
|
||||
{
|
||||
glLoadIdentity();
|
||||
|
||||
glTranslated(0.0, 0.0, -1.0);
|
||||
|
||||
glRotatef( 55, 1, 0, 0 );
|
||||
glRotatef( 45, 0, 1, 0 );
|
||||
glRotatef( 0, 0, 0, 1 );
|
||||
|
||||
static const int coords[6][4][3] = {
|
||||
{ { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } },
|
||||
{ { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } },
|
||||
{ { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } },
|
||||
{ { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } },
|
||||
{ { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } },
|
||||
{ { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } }
|
||||
};
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
glColor3ub( i*20, 100+i*10, i*42 );
|
||||
glBegin(GL_QUADS);
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
@endcode
|
||||
|
||||
@param winname Name of the window.
|
||||
@param onOpenGlDraw Pointer to the function to be called every frame. This function should be
|
||||
prototyped as void Foo(void\*) .
|
||||
@param userdata Pointer passed to the callback function.(__Optional__)
|
||||
*/
|
||||
CV_EXPORTS void setOpenGlDrawCallback(const String& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
|
||||
|
||||
/** @brief Sets the specified window as current OpenGL context.
|
||||
|
||||
@param winname Name of the window.
|
||||
*/
|
||||
CV_EXPORTS void setOpenGlContext(const String& winname);
|
||||
|
||||
/** @brief Force window to redraw its context and call draw callback ( See cv::setOpenGlDrawCallback ).
|
||||
|
||||
@param winname Name of the window.
|
||||
*/
|
||||
CV_EXPORTS void updateWindow(const String& winname);
|
||||
|
||||
//! @} highgui_opengl
|
||||
|
||||
//! @addtogroup highgui_qt
|
||||
//! @{
|
||||
|
||||
/** @brief QtFont available only for Qt. See cv::fontQt
|
||||
*/
|
||||
struct QtFont
|
||||
{
|
||||
const char* nameFont; //!< Name of the font
|
||||
Scalar color; //!< Color of the font. Scalar(blue_component, green_component, red_component[, alpha_component])
|
||||
int font_face; //!< See cv::QtFontStyles
|
||||
const int* ascii; //!< font data and metrics
|
||||
const int* greek;
|
||||
const int* cyrillic;
|
||||
float hscale, vscale;
|
||||
float shear; //!< slope coefficient: 0 - normal, >0 - italic
|
||||
int thickness; //!< See cv::QtFontWeights
|
||||
float dx; //!< horizontal interval between letters
|
||||
int line_type; //!< PointSize
|
||||
};
|
||||
|
||||
/** @brief Creates the font to draw a text on an image.
|
||||
|
||||
The function fontQt creates a cv::QtFont object. This cv::QtFont is not compatible with putText .
|
||||
|
||||
A basic usage of this function is the following: :
|
||||
@code
|
||||
QtFont font = fontQt("Times");
|
||||
addText( img1, "Hello World !", Point(50,50), font);
|
||||
@endcode
|
||||
|
||||
@param nameFont Name of the font. The name should match the name of a system font (such as
|
||||
*Times*). If the font is not found, a default one is used.
|
||||
@param pointSize Size of the font. If not specified, equal zero or negative, the point size of the
|
||||
font is set to a system-dependent default value. Generally, this is 12 points.
|
||||
@param color Color of the font in BGRA where A = 255 is fully transparent. Use the macro CV_RGB
|
||||
for simplicity.
|
||||
@param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.
|
||||
@param style Font style. Available operation flags are : cv::QtFontStyles
|
||||
@param spacing Spacing between characters. It can be negative or positive.
|
||||
*/
|
||||
CV_EXPORTS QtFont fontQt(const String& nameFont, int pointSize = -1,
|
||||
Scalar color = Scalar::all(0), int weight = QT_FONT_NORMAL,
|
||||
int style = QT_STYLE_NORMAL, int spacing = 0);
|
||||
|
||||
/** @brief Draws a text on the image.
|
||||
|
||||
The function addText draws *text* on the image *img* using a specific font *font* (see example cv::fontQt
|
||||
)
|
||||
|
||||
@param img 8-bit 3-channel image where the text should be drawn.
|
||||
@param text Text to write on an image.
|
||||
@param org Point(x,y) where the text should start on an image.
|
||||
@param font Font to use to draw a text.
|
||||
*/
|
||||
CV_EXPORTS void addText( const Mat& img, const String& text, Point org, const QtFont& font);
|
||||
|
||||
/** @brief Draws a text on the image.
|
||||
|
||||
@param img 8-bit 3-channel image where the text should be drawn.
|
||||
@param text Text to write on an image.
|
||||
@param org Point(x,y) where the text should start on an image.
|
||||
@param nameFont Name of the font. The name should match the name of a system font (such as
|
||||
*Times*). If the font is not found, a default one is used.
|
||||
@param pointSize Size of the font. If not specified, equal zero or negative, the point size of the
|
||||
font is set to a system-dependent default value. Generally, this is 12 points.
|
||||
@param color Color of the font in BGRA where A = 255 is fully transparent.
|
||||
@param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.
|
||||
@param style Font style. Available operation flags are : cv::QtFontStyles
|
||||
@param spacing Spacing between characters. It can be negative or positive.
|
||||
*/
|
||||
CV_EXPORTS_W void addText(const Mat& img, const String& text, Point org, const String& nameFont, int pointSize = -1, Scalar color = Scalar::all(0),
|
||||
int weight = QT_FONT_NORMAL, int style = QT_STYLE_NORMAL, int spacing = 0);
|
||||
|
||||
/** @brief Displays a text on a window image as an overlay for a specified duration.
|
||||
|
||||
The function displayOverlay displays useful information/tips on top of the window for a certain
|
||||
amount of time *delayms*. The function does not modify the image, displayed in the window, that is,
|
||||
after the specified delay the original content of the window is restored.
|
||||
|
||||
@param winname Name of the window.
|
||||
@param text Overlay text to write on a window image.
|
||||
@param delayms The period (in milliseconds), during which the overlay text is displayed. If this
|
||||
function is called before the previous overlay text timed out, the timer is restarted and the text
|
||||
is updated. If this value is zero, the text never disappears.
|
||||
*/
|
||||
CV_EXPORTS_W void displayOverlay(const String& winname, const String& text, int delayms = 0);
|
||||
|
||||
/** @brief Displays a text on the window statusbar during the specified period of time.
|
||||
|
||||
The function displayStatusBar displays useful information/tips on top of the window for a certain
|
||||
amount of time *delayms* . This information is displayed on the window statusbar (the window must be
|
||||
created with the CV_GUI_EXPANDED flags).
|
||||
|
||||
@param winname Name of the window.
|
||||
@param text Text to write on the window statusbar.
|
||||
@param delayms Duration (in milliseconds) to display the text. If this function is called before
|
||||
the previous text timed out, the timer is restarted and the text is updated. If this value is
|
||||
zero, the text never disappears.
|
||||
*/
|
||||
CV_EXPORTS_W void displayStatusBar(const String& winname, const String& text, int delayms = 0);
|
||||
|
||||
/** @brief Saves parameters of the specified window.
|
||||
|
||||
The function saveWindowParameters saves size, location, flags, trackbars value, zoom and panning
|
||||
location of the window windowName.
|
||||
|
||||
@param windowName Name of the window.
|
||||
*/
|
||||
CV_EXPORTS void saveWindowParameters(const String& windowName);
|
||||
|
||||
/** @brief Loads parameters of the specified window.
|
||||
|
||||
The function loadWindowParameters loads size, location, flags, trackbars value, zoom and panning
|
||||
location of the window windowName.
|
||||
|
||||
@param windowName Name of the window.
|
||||
*/
|
||||
CV_EXPORTS void loadWindowParameters(const String& windowName);
|
||||
|
||||
CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
||||
|
||||
CV_EXPORTS void stopLoop();
|
||||
|
||||
/** @brief Attaches a button to the control panel.
|
||||
|
||||
The function createButton attaches a button to the control panel. Each button is added to a
|
||||
buttonbar to the right of the last button. A new buttonbar is created if nothing was attached to the
|
||||
control panel before, or if the last element attached to the control panel was a trackbar or if the
|
||||
QT_NEW_BUTTONBAR flag is added to the type.
|
||||
|
||||
See below various examples of the cv::createButton function call: :
|
||||
@code
|
||||
createButton("",callbackButton);//create a push button "button 0", that will call callbackButton.
|
||||
createButton("button2",callbackButton,NULL,QT_CHECKBOX,0);
|
||||
createButton("button3",callbackButton,&value);
|
||||
createButton("button5",callbackButton1,NULL,QT_RADIOBOX);
|
||||
createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON,1);
|
||||
createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON|QT_NEW_BUTTONBAR);// create a push button in a new row
|
||||
@endcode
|
||||
|
||||
@param bar_name Name of the button.
|
||||
@param on_change Pointer to the function to be called every time the button changes its state.
|
||||
This function should be prototyped as void Foo(int state,\*void); . *state* is the current state
|
||||
of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
|
||||
@param userdata Pointer passed to the callback function.
|
||||
@param type Optional type of the button. Available types are: (cv::QtButtonTypes)
|
||||
@param initial_button_state Default state of the button. Use for checkbox and radiobox. Its
|
||||
value could be 0 or 1. (__Optional__)
|
||||
*/
|
||||
CV_EXPORTS int createButton( const String& bar_name, ButtonCallback on_change,
|
||||
void* userdata = 0, int type = QT_PUSH_BUTTON,
|
||||
bool initial_button_state = false);
|
||||
|
||||
//! @} highgui_qt
|
||||
|
||||
//! @} highgui
|
||||
|
||||
} // cv
|
||||
|
||||
#endif
|
48
3rdparty/opencv-4.5.4/modules/highgui/include/opencv2/highgui/highgui.hpp
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/highgui.hpp"
|
256
3rdparty/opencv-4.5.4/modules/highgui/include/opencv2/highgui/highgui_c.h
vendored
Normal file
@ -0,0 +1,256 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_HIGHGUI_H
|
||||
#define OPENCV_HIGHGUI_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/** @addtogroup highgui_c
|
||||
@{
|
||||
*/
|
||||
|
||||
/****************************************************************************************\
|
||||
* Basic GUI functions *
|
||||
\****************************************************************************************/
|
||||
//YV
|
||||
//-----------New for Qt
|
||||
/* For font */
|
||||
enum { CV_FONT_LIGHT = 25,//QFont::Light,
|
||||
CV_FONT_NORMAL = 50,//QFont::Normal,
|
||||
CV_FONT_DEMIBOLD = 63,//QFont::DemiBold,
|
||||
CV_FONT_BOLD = 75,//QFont::Bold,
|
||||
CV_FONT_BLACK = 87 //QFont::Black
|
||||
};
|
||||
|
||||
enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
|
||||
CV_STYLE_ITALIC = 1,//QFont::StyleItalic,
|
||||
CV_STYLE_OBLIQUE = 2 //QFont::StyleOblique
|
||||
};
|
||||
/* ---------*/
|
||||
|
||||
//for color cvScalar(blue_component, green_component, red_component[, alpha_component])
|
||||
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
|
||||
CVAPI(CvFont) cvFontQt(const char* nameFont, int pointSize CV_DEFAULT(-1), CvScalar color CV_DEFAULT(cvScalarAll(0)), int weight CV_DEFAULT(CV_FONT_NORMAL), int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0));
|
||||
|
||||
CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *arg2);
|
||||
|
||||
CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms CV_DEFAULT(0));
|
||||
CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms CV_DEFAULT(0));
|
||||
|
||||
CVAPI(void) cvSaveWindowParameters(const char* name);
|
||||
CVAPI(void) cvLoadWindowParameters(const char* name);
|
||||
CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
||||
CVAPI(void) cvStopLoop( void );
|
||||
|
||||
typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
|
||||
enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2};
|
||||
CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0));
|
||||
//----------------------
|
||||
|
||||
|
||||
/* this function is used to set some external parameters in case of X Window */
|
||||
CVAPI(int) cvInitSystem( int argc, char** argv );
|
||||
|
||||
CVAPI(int) cvStartWindowThread( void );
|
||||
|
||||
// --------- YV ---------
|
||||
enum
|
||||
{
|
||||
//These 3 flags are used by cvSet/GetWindowProperty
|
||||
CV_WND_PROP_FULLSCREEN = 0, //to change/get window's fullscreen property
|
||||
CV_WND_PROP_AUTOSIZE = 1, //to change/get window's autosize property
|
||||
CV_WND_PROP_ASPECTRATIO= 2, //to change/get window's aspectratio property
|
||||
CV_WND_PROP_OPENGL = 3, //to change/get window's opengl support
|
||||
CV_WND_PROP_VISIBLE = 4,
|
||||
|
||||
//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
|
||||
CV_WINDOW_NORMAL = 0x00000000, //the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
|
||||
CV_WINDOW_AUTOSIZE = 0x00000001, //the user cannot resize the window, the size is constrainted by the image displayed
|
||||
CV_WINDOW_OPENGL = 0x00001000, //window with opengl support
|
||||
|
||||
//Those flags are only for Qt
|
||||
CV_GUI_EXPANDED = 0x00000000, //status bar and tool bar
|
||||
CV_GUI_NORMAL = 0x00000010, //old fashious way
|
||||
|
||||
//These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
|
||||
CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen
|
||||
CV_WINDOW_FREERATIO = 0x00000100,//the image expends as much as it can (no ratio constraint)
|
||||
CV_WINDOW_KEEPRATIO = 0x00000000//the ration image is respected.
|
||||
};
|
||||
|
||||
/* create window */
|
||||
CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
|
||||
|
||||
/* Set and Get Property of the window */
|
||||
CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value);
|
||||
CVAPI(double) cvGetWindowProperty(const char* name, int prop_id);
|
||||
|
||||
#ifdef __cplusplus // FIXIT remove in OpenCV 4.0
|
||||
/* Get window image rectangle coordinates, width and height */
|
||||
CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);
|
||||
#endif
|
||||
|
||||
/* display image within window (highgui windows remember their content) */
|
||||
CVAPI(void) cvShowImage( const char* name, const CvArr* image );
|
||||
|
||||
/* resize/move window */
|
||||
CVAPI(void) cvResizeWindow( const char* name, int width, int height );
|
||||
CVAPI(void) cvMoveWindow( const char* name, int x, int y );
|
||||
|
||||
|
||||
/* destroy window and all the trackers associated with it */
|
||||
CVAPI(void) cvDestroyWindow( const char* name );
|
||||
|
||||
CVAPI(void) cvDestroyAllWindows(void);
|
||||
|
||||
/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */
|
||||
CVAPI(void*) cvGetWindowHandle( const char* name );
|
||||
|
||||
/* get name of highgui window given its native handle */
|
||||
CVAPI(const char*) cvGetWindowName( void* window_handle );
|
||||
|
||||
|
||||
typedef void (CV_CDECL *CvTrackbarCallback)(int pos);
|
||||
|
||||
/* create trackbar and display it on top of given window, set callback */
|
||||
CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name,
|
||||
int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL));
|
||||
|
||||
typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata);
|
||||
|
||||
CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
|
||||
int* value, int count, CvTrackbarCallback2 on_change,
|
||||
void* userdata CV_DEFAULT(0));
|
||||
|
||||
/* retrieve or set trackbar position */
|
||||
CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
|
||||
CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
|
||||
CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval);
|
||||
CVAPI(void) cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval);
|
||||
|
||||
enum
|
||||
{
|
||||
CV_EVENT_MOUSEMOVE =0,
|
||||
CV_EVENT_LBUTTONDOWN =1,
|
||||
CV_EVENT_RBUTTONDOWN =2,
|
||||
CV_EVENT_MBUTTONDOWN =3,
|
||||
CV_EVENT_LBUTTONUP =4,
|
||||
CV_EVENT_RBUTTONUP =5,
|
||||
CV_EVENT_MBUTTONUP =6,
|
||||
CV_EVENT_LBUTTONDBLCLK =7,
|
||||
CV_EVENT_RBUTTONDBLCLK =8,
|
||||
CV_EVENT_MBUTTONDBLCLK =9,
|
||||
CV_EVENT_MOUSEWHEEL =10,
|
||||
CV_EVENT_MOUSEHWHEEL =11
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CV_EVENT_FLAG_LBUTTON =1,
|
||||
CV_EVENT_FLAG_RBUTTON =2,
|
||||
CV_EVENT_FLAG_MBUTTON =4,
|
||||
CV_EVENT_FLAG_CTRLKEY =8,
|
||||
CV_EVENT_FLAG_SHIFTKEY =16,
|
||||
CV_EVENT_FLAG_ALTKEY =32
|
||||
};
|
||||
|
||||
|
||||
#define CV_GET_WHEEL_DELTA(flags) ((short)((flags >> 16) & 0xffff)) // upper 16 bits
|
||||
|
||||
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
|
||||
|
||||
/* assign callback for mouse events */
|
||||
CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,
|
||||
void* param CV_DEFAULT(NULL));
|
||||
|
||||
/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
|
||||
CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
|
||||
|
||||
// OpenGL support
|
||||
|
||||
typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata);
|
||||
CVAPI(void) cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata CV_DEFAULT(NULL));
|
||||
|
||||
CVAPI(void) cvSetOpenGlContext(const char* window_name);
|
||||
CVAPI(void) cvUpdateWindow(const char* window_name);
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
|
||||
* Obsolete functions/synonyms *
|
||||
\****************************************************************************************/
|
||||
|
||||
#define cvAddSearchPath(path)
|
||||
#define cvvInitSystem cvInitSystem
|
||||
#define cvvNamedWindow cvNamedWindow
|
||||
#define cvvShowImage cvShowImage
|
||||
#define cvvResizeWindow cvResizeWindow
|
||||
#define cvvDestroyWindow cvDestroyWindow
|
||||
#define cvvCreateTrackbar cvCreateTrackbar
|
||||
#define cvvAddSearchPath cvAddSearchPath
|
||||
#define cvvWaitKey(name) cvWaitKey(0)
|
||||
#define cvvWaitKeyEx(name,delay) cvWaitKey(delay)
|
||||
#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
|
||||
#define set_preprocess_func cvSetPreprocessFuncWin32
|
||||
#define set_postprocess_func cvSetPostprocessFuncWin32
|
||||
|
||||
#if defined _WIN32
|
||||
|
||||
CVAPI(void) cvSetPreprocessFuncWin32_(const void* callback);
|
||||
CVAPI(void) cvSetPostprocessFuncWin32_(const void* callback);
|
||||
#define cvSetPreprocessFuncWin32(callback) cvSetPreprocessFuncWin32_((const void*)(callback))
|
||||
#define cvSetPostprocessFuncWin32(callback) cvSetPostprocessFuncWin32_((const void*)(callback))
|
||||
|
||||
#endif
|
||||
|
||||
/** @} highgui_c */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
48
3rdparty/opencv-4.5.4/modules/highgui/include/opencv2/highgui/highgui_winrt.hpp
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
// highgui (UX) support for Windows Runtime
|
||||
|
||||
// Copyright (c) Microsoft Open Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// (3 - clause BSD License)
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
|
||||
// the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
// following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
||||
// following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or
|
||||
// promote products derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
// PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using namespace Windows::UI::Xaml::Controls;
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup highgui_winrt
|
||||
//! @{
|
||||
|
||||
/********************************** WinRT Specific API *************************************************/
|
||||
|
||||
/** @brief Initializes container component that will be used to hold generated window content.
|
||||
|
||||
@param container Container (Panel^) reference that will be used to hold generated window content: controls and image.
|
||||
|
||||
@note
|
||||
Must be called to assign WinRT container that will hold created windows content.
|
||||
*/
|
||||
CV_EXPORTS void winrt_initContainer(::Windows::UI::Xaml::Controls::Panel^ container);
|
||||
|
||||
//! @} videoio_winrt
|
||||
|
||||
} // cv
|
0
3rdparty/opencv-4.5.4/modules/highgui/misc/java/filelist
vendored
Normal file
193
3rdparty/opencv-4.5.4/modules/highgui/misc/java/src/java/highgui+HighGui.java
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
package org.opencv.highgui;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* This class was designed for use in Java applications
|
||||
* to recreate the OpenCV HighGui functionalities.
|
||||
*/
|
||||
public final class HighGui {
|
||||
|
||||
// Constants for namedWindow
|
||||
public final static int WINDOW_NORMAL = ImageWindow.WINDOW_NORMAL;
|
||||
public final static int WINDOW_AUTOSIZE = ImageWindow.WINDOW_AUTOSIZE;
|
||||
|
||||
// Control Variables
|
||||
public static int n_closed_windows = 0;
|
||||
public static int pressedKey = -1;
|
||||
public static CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
// Windows Map
|
||||
public static Map<String, ImageWindow> windows = new HashMap<String, ImageWindow>();
|
||||
|
||||
public static void namedWindow(String winname) {
|
||||
namedWindow(winname, HighGui.WINDOW_AUTOSIZE);
|
||||
}
|
||||
|
||||
public static void namedWindow(String winname, int flag) {
|
||||
ImageWindow newWin = new ImageWindow(winname, flag);
|
||||
if (windows.get(winname) == null) windows.put(winname, newWin);
|
||||
}
|
||||
|
||||
public static void imshow(String winname, Mat img) {
|
||||
if (img.empty()) {
|
||||
System.err.println("Error: Empty image in imshow");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
ImageWindow tmpWindow = windows.get(winname);
|
||||
if (tmpWindow == null) {
|
||||
ImageWindow newWin = new ImageWindow(winname, img);
|
||||
windows.put(winname, newWin);
|
||||
} else {
|
||||
tmpWindow.setMat(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Image toBufferedImage(Mat m) {
|
||||
int type = BufferedImage.TYPE_BYTE_GRAY;
|
||||
|
||||
if (m.channels() > 1) {
|
||||
type = BufferedImage.TYPE_3BYTE_BGR;
|
||||
}
|
||||
|
||||
int bufferSize = m.channels() * m.cols() * m.rows();
|
||||
byte[] b = new byte[bufferSize];
|
||||
m.get(0, 0, b); // get all the pixels
|
||||
BufferedImage image = new BufferedImage(m.cols(), m.rows(), type);
|
||||
|
||||
final byte[] targetPixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
|
||||
System.arraycopy(b, 0, targetPixels, 0, b.length);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
public static JFrame createJFrame(String title, int flag) {
|
||||
JFrame frame = new JFrame(title);
|
||||
|
||||
frame.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
|
||||
n_closed_windows++;
|
||||
if (n_closed_windows == windows.size()) latch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
frame.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
pressedKey = e.getKeyCode();
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
if (flag == WINDOW_AUTOSIZE) frame.setResizable(false);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
public static void waitKey(){
|
||||
waitKey(0);
|
||||
}
|
||||
|
||||
public static int waitKey(int delay) {
|
||||
// Reset control values
|
||||
latch = new CountDownLatch(1);
|
||||
n_closed_windows = 0;
|
||||
pressedKey = -1;
|
||||
|
||||
// If there are no windows to be shown return
|
||||
if (windows.isEmpty()) {
|
||||
System.err.println("Error: waitKey must be used after an imshow");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// Remove the unused windows
|
||||
Iterator<Map.Entry<String,
|
||||
ImageWindow>> iter = windows.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String,
|
||||
ImageWindow> entry = iter.next();
|
||||
ImageWindow win = entry.getValue();
|
||||
if (win.alreadyUsed) {
|
||||
iter.remove();
|
||||
win.frame.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// (if) Create (else) Update frame
|
||||
for (ImageWindow win : windows.values()) {
|
||||
|
||||
if (win.img != null) {
|
||||
|
||||
ImageIcon icon = new ImageIcon(toBufferedImage(win.img));
|
||||
|
||||
if (win.lbl == null) {
|
||||
JFrame frame = createJFrame(win.name, win.flag);
|
||||
JLabel lbl = new JLabel(icon);
|
||||
win.setFrameLabelVisible(frame, lbl);
|
||||
} else {
|
||||
win.lbl.setIcon(icon);
|
||||
}
|
||||
} else {
|
||||
System.err.println("Error: no imshow associated with" + " namedWindow: \"" + win.name + "\"");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (delay == 0) {
|
||||
latch.await();
|
||||
} else {
|
||||
latch.await(delay, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Set all windows as already used
|
||||
for (ImageWindow win : windows.values())
|
||||
win.alreadyUsed = true;
|
||||
|
||||
return pressedKey;
|
||||
}
|
||||
|
||||
public static void destroyWindow(String winname) {
|
||||
ImageWindow tmpWin = windows.get(winname);
|
||||
if (tmpWin != null) windows.remove(winname);
|
||||
}
|
||||
|
||||
public static void destroyAllWindows() {
|
||||
windows.clear();
|
||||
}
|
||||
|
||||
public static void resizeWindow(String winname, int width, int height) {
|
||||
ImageWindow tmpWin = windows.get(winname);
|
||||
if (tmpWin != null) tmpWin.setNewDimension(width, height);
|
||||
}
|
||||
|
||||
public static void moveWindow(String winname, int x, int y) {
|
||||
ImageWindow tmpWin = windows.get(winname);
|
||||
if (tmpWin != null) tmpWin.setNewPosition(x, y);
|
||||
}
|
||||
}
|
132
3rdparty/opencv-4.5.4/modules/highgui/misc/java/src/java/highgui+ImageWindow.java
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
package org.opencv.highgui;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* This class was designed to create and manipulate
|
||||
* the Windows to be used by the HighGui class.
|
||||
*/
|
||||
public final class ImageWindow {
|
||||
|
||||
public final static int WINDOW_NORMAL = 0;
|
||||
public final static int WINDOW_AUTOSIZE = 1;
|
||||
|
||||
public String name;
|
||||
public Mat img = null;
|
||||
public Boolean alreadyUsed = false;
|
||||
public Boolean imgToBeResized = false;
|
||||
public Boolean windowToBeResized = false;
|
||||
public Boolean positionToBeChanged = false;
|
||||
public JFrame frame = null;
|
||||
public JLabel lbl = null;
|
||||
public int flag;
|
||||
public int x = -1;
|
||||
public int y = -1;
|
||||
public int width = -1;
|
||||
public int height = -1;
|
||||
|
||||
public ImageWindow(String name, Mat img) {
|
||||
this.name = name;
|
||||
this.img = img;
|
||||
this.flag = WINDOW_NORMAL;
|
||||
}
|
||||
|
||||
public ImageWindow(String name, int flag) {
|
||||
this.name = name;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public static Size keepAspectRatioSize(int original_width, int original_height, int bound_width, int bound_height) {
|
||||
|
||||
int new_width = original_width;
|
||||
int new_height = original_height;
|
||||
|
||||
if (original_width > bound_width) {
|
||||
new_width = bound_width;
|
||||
new_height = (new_width * original_height) / original_width;
|
||||
}
|
||||
|
||||
if (new_height > bound_height) {
|
||||
new_height = bound_height;
|
||||
new_width = (new_height * original_width) / original_height;
|
||||
}
|
||||
|
||||
return new Size(new_width, new_height);
|
||||
}
|
||||
|
||||
public void setMat(Mat img) {
|
||||
|
||||
this.img = img;
|
||||
this.alreadyUsed = false;
|
||||
|
||||
if (imgToBeResized) {
|
||||
resizeImage();
|
||||
imgToBeResized = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setFrameLabelVisible(JFrame frame, JLabel lbl) {
|
||||
this.frame = frame;
|
||||
this.lbl = lbl;
|
||||
|
||||
if (windowToBeResized) {
|
||||
lbl.setPreferredSize(new Dimension(width, height));
|
||||
windowToBeResized = false;
|
||||
}
|
||||
|
||||
if (positionToBeChanged) {
|
||||
frame.setLocation(x, y);
|
||||
positionToBeChanged = false;
|
||||
}
|
||||
|
||||
frame.add(lbl);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public void setNewDimension(int width, int height) {
|
||||
|
||||
if (this.width != width || this.height != height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
if (img != null) {
|
||||
resizeImage();
|
||||
} else {
|
||||
imgToBeResized = true;
|
||||
}
|
||||
|
||||
if (lbl != null) {
|
||||
lbl.setPreferredSize(new Dimension(width, height));
|
||||
} else {
|
||||
windowToBeResized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNewPosition(int x, int y) {
|
||||
if (this.x != x || this.y != y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
if (frame != null) {
|
||||
frame.setLocation(x, y);
|
||||
} else {
|
||||
positionToBeChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resizeImage() {
|
||||
if (flag == WINDOW_NORMAL) {
|
||||
Size tmpSize = keepAspectRatioSize(img.width(), img.height(), width, height);
|
||||
Imgproc.resize(img, img, tmpSize, 0, 0, Imgproc.INTER_LINEAR_EXACT);
|
||||
}
|
||||
}
|
||||
}
|
72
3rdparty/opencv-4.5.4/modules/highgui/misc/plugins/build_plugins.sh
vendored
Executable file
@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z $1 ] ; then
|
||||
echo "$0 <destination directory>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
OCV="$( cd "${DIR}/../../../.." >/dev/null 2>&1 && pwd )"
|
||||
mkdir -p "${1}" # Docker creates non-existed mounts with 'root' owner, lets ensure that dir exists under the current user to avoid "Permission denied" problem
|
||||
DST="$( cd "$1" >/dev/null 2>&1 && pwd )"
|
||||
CFG=${2:-Release}
|
||||
|
||||
do_build()
|
||||
{
|
||||
TAG=$1
|
||||
D=$2
|
||||
F=$3
|
||||
shift 3
|
||||
docker build \
|
||||
--build-arg http_proxy \
|
||||
--build-arg https_proxy \
|
||||
$@ \
|
||||
-t $TAG \
|
||||
-f "${D}/${F}" \
|
||||
"${D}"
|
||||
}
|
||||
|
||||
do_run()
|
||||
{
|
||||
TAG=$1
|
||||
shift 1
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
-v "${OCV}":/opencv:ro \
|
||||
-v "${DST}":/dst \
|
||||
-e CFG=$CFG \
|
||||
--user $(id -u):$(id -g) \
|
||||
$TAG \
|
||||
"$@"
|
||||
}
|
||||
|
||||
build_gtk2_ubuntu()
|
||||
{
|
||||
VER=$1
|
||||
shift 1
|
||||
TAG=opencv_highgui_ubuntu_gtk2_builder:${VER}
|
||||
do_build $TAG "${DIR}/plugin_gtk" Dockerfile-ubuntu-gtk2 --build-arg VER=${VER}
|
||||
do_run $TAG /opencv/modules/highgui/misc/plugins/plugin_gtk/build.sh /dst gtk2_ubuntu${VER} ${CFG} "$@"
|
||||
|
||||
}
|
||||
|
||||
build_gtk3_ubuntu()
|
||||
{
|
||||
VER=$1
|
||||
shift 1
|
||||
TAG=opencv_highgui_ubuntu_gtk3_builder:${VER}
|
||||
do_build $TAG "${DIR}/plugin_gtk" Dockerfile-ubuntu-gtk3 --build-arg VER=${VER}
|
||||
do_run $TAG /opencv/modules/highgui/misc/plugins/plugin_gtk/build.sh /dst gtk3_ubuntu${VER} ${CFG} "$@"
|
||||
}
|
||||
|
||||
echo "OpenCV: ${OCV}"
|
||||
echo "Destination: ${DST}"
|
||||
|
||||
build_gtk2_ubuntu 16.04
|
||||
build_gtk2_ubuntu 16.04 -DOPENCV_PLUGIN_NAME=opencv_highgui_gtk2-opengl_ubuntu16.04 -DWITH_OPENGL=ON -DWITH_GTK_2_X=ON
|
||||
build_gtk2_ubuntu 18.04
|
||||
build_gtk3_ubuntu 18.04
|
||||
build_gtk3_ubuntu 20.04
|
58
3rdparty/opencv-4.5.4/modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(opencv_highgui_gtk)
|
||||
|
||||
get_filename_component(OpenCV_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../.." ABSOLUTE)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVPluginStandalone.cmake")
|
||||
|
||||
# scan dependencies
|
||||
set(WITH_GTK ON)
|
||||
include("${OpenCV_SOURCE_DIR}/modules/highgui/cmake/init.cmake")
|
||||
|
||||
if(NOT HAVE_GTK)
|
||||
message(FATAL_ERROR "GTK: NO")
|
||||
endif()
|
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
|
||||
|
||||
set(OPENCV_PLUGIN_DEPS core imgproc imgcodecs)
|
||||
if(TARGET ocv.3rdparty.gtk3)
|
||||
set(__deps ocv.3rdparty.gtk3)
|
||||
elseif(TARGET ocv.3rdparty.gtk2)
|
||||
set(__deps ocv.3rdparty.gtk2)
|
||||
elseif(TARGET ocv.3rdparty.gtk)
|
||||
set(__deps ocv.3rdparty.gtk)
|
||||
else()
|
||||
message(FATAL_ERROR "Missing dependency target for GTK libraries")
|
||||
endif()
|
||||
ocv_create_plugin(highgui "opencv_highgui_gtk" "${__deps}" "GTK" "src/window_gtk.cpp")
|
||||
if(WITH_OPENGL)
|
||||
if(HAVE_GTK2
|
||||
AND TARGET ocv.3rdparty.gtkglext
|
||||
AND TARGET ocv.3rdparty.gtk_opengl
|
||||
AND NOT OPENCV_GTK_DISABLE_GTKGLEXT
|
||||
AND NOT OPENCV_GTK_DISABLE_OPENGL
|
||||
)
|
||||
message(STATUS "OpenGL: YES")
|
||||
target_link_libraries(${OPENCV_PLUGIN_NAME} PRIVATE
|
||||
ocv.3rdparty.gtkglext ocv.3rdparty.gtk_opengl
|
||||
)
|
||||
else()
|
||||
message(WARNING "OpenGL dependencies are not available!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_GTK3)
|
||||
message(STATUS "GTK3+: ver ${GTK3_VERSION}")
|
||||
elseif(HAVE_GTK3)
|
||||
message(STATUS "GTK2+: ver ${GTK2_VERSION}")
|
||||
elseif(DEFINED GTK_VERSION)
|
||||
message(STATUS "GTK+: ver ${GTK_VERSION}")
|
||||
else()
|
||||
message(STATUS "GTK+: YES")
|
||||
endif()
|
||||
|
||||
if(HAVE_GTHREAD)
|
||||
message(STATUS "GThread : YES (ver ${GTHREAD_VERSION})")
|
||||
else()
|
||||
message(STATUS "GThread : NO")
|
||||
endif()
|
28
3rdparty/opencv-4.5.4/modules/highgui/misc/plugins/plugin_gtk/Dockerfile-ubuntu-gtk2
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
ARG VER
|
||||
FROM ubuntu:$VER
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
pkg-config \
|
||||
cmake \
|
||||
g++ \
|
||||
ninja-build \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
libgtk2.0-dev \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
libgtkglext1-dev \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /tmp
|
21
3rdparty/opencv-4.5.4/modules/highgui/misc/plugins/plugin_gtk/Dockerfile-ubuntu-gtk3
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
ARG VER
|
||||
FROM ubuntu:$VER
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
pkg-config \
|
||||
cmake \
|
||||
g++ \
|
||||
ninja-build \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
libgtk-3-dev \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /tmp
|
21
3rdparty/opencv-4.5.4/modules/highgui/misc/plugins/plugin_gtk/build.sh
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
OPENCV_PLUGIN_DESTINATION=$1
|
||||
OPENCV_PLUGIN_NAME=opencv_highgui_$2
|
||||
CMAKE_BUILD_TYPE=${3:-Release}
|
||||
|
||||
shift 3 || true
|
||||
|
||||
set -x
|
||||
cmake -GNinja \
|
||||
-DOPENCV_PLUGIN_NAME=${OPENCV_PLUGIN_NAME} \
|
||||
-DOPENCV_PLUGIN_DESTINATION=${OPENCV_PLUGIN_DESTINATION} \
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
|
||||
"$@" \
|
||||
$DIR
|
||||
|
||||
ninja -v
|
181
3rdparty/opencv-4.5.4/modules/highgui/src/backend.cpp
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "precomp.hpp"
|
||||
#include "backend.hpp"
|
||||
|
||||
#include <opencv2/core/utils/configuration.private.hpp>
|
||||
#include <opencv2/core/utils/logger.defines.hpp>
|
||||
#ifdef NDEBUG
|
||||
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG + 1
|
||||
#else
|
||||
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
|
||||
#endif
|
||||
#include <opencv2/core/utils/logger.hpp>
|
||||
|
||||
|
||||
#include "registry.hpp"
|
||||
#include "registry.impl.hpp"
|
||||
|
||||
#include "plugin_api.hpp"
|
||||
#include "plugin_wrapper.impl.hpp"
|
||||
|
||||
|
||||
namespace cv { namespace highgui_backend {
|
||||
|
||||
UIBackend::~UIBackend()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
UIWindowBase::~UIWindowBase()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
UIWindow::~UIWindow()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
UITrackbar::~UITrackbar()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
static
|
||||
std::string& getUIBackendName()
|
||||
{
|
||||
static std::string g_backendName = toUpperCase(cv::utils::getConfigurationParameterString("OPENCV_UI_BACKEND", ""));
|
||||
return g_backendName;
|
||||
}
|
||||
|
||||
static bool g_initializedUIBackend = false;
|
||||
|
||||
static
|
||||
std::shared_ptr<UIBackend> createUIBackend()
|
||||
{
|
||||
const std::string& name = getUIBackendName();
|
||||
bool isKnown = false;
|
||||
const auto& backends = getBackendsInfo();
|
||||
if (!name.empty())
|
||||
{
|
||||
CV_LOG_INFO(NULL, "UI: requested backend name: " << name);
|
||||
}
|
||||
for (size_t i = 0; i < backends.size(); i++)
|
||||
{
|
||||
const auto& info = backends[i];
|
||||
if (!name.empty())
|
||||
{
|
||||
if (name != info.name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
isKnown = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
CV_LOG_DEBUG(NULL, "UI: trying backend: " << info.name << " (priority=" << info.priority << ")");
|
||||
if (!info.backendFactory)
|
||||
{
|
||||
CV_LOG_DEBUG(NULL, "UI: factory is not available (plugins require filesystem support): " << info.name);
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<UIBackend> backend = info.backendFactory->create();
|
||||
if (!backend)
|
||||
{
|
||||
CV_LOG_VERBOSE(NULL, 0, "UI: not available: " << info.name);
|
||||
continue;
|
||||
}
|
||||
CV_LOG_INFO(NULL, "UI: using backend: " << info.name << " (priority=" << info.priority << ")");
|
||||
g_initializedUIBackend = true;
|
||||
getUIBackendName() = info.name;
|
||||
return backend;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
CV_LOG_WARNING(NULL, "UI: can't initialize " << info.name << " backend: " << e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
CV_LOG_WARNING(NULL, "UI: can't initialize " << info.name << " backend: Unknown C++ exception");
|
||||
}
|
||||
}
|
||||
if (name.empty())
|
||||
{
|
||||
CV_LOG_DEBUG(NULL, "UI: fallback on builtin code: " OPENCV_HIGHGUI_BUILTIN_BACKEND_STR);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isKnown)
|
||||
CV_LOG_INFO(NULL, "UI: unknown backend: " << name);
|
||||
}
|
||||
g_initializedUIBackend = true;
|
||||
return std::shared_ptr<UIBackend>();
|
||||
}
|
||||
|
||||
static inline
|
||||
std::shared_ptr<UIBackend> createDefaultUIBackend()
|
||||
{
|
||||
CV_LOG_DEBUG(NULL, "UI: Initializing backend...");
|
||||
return createUIBackend();
|
||||
}
|
||||
|
||||
std::shared_ptr<UIBackend>& getCurrentUIBackend()
|
||||
{
|
||||
static std::shared_ptr<UIBackend> g_currentUIBackend = createDefaultUIBackend();
|
||||
return g_currentUIBackend;
|
||||
}
|
||||
|
||||
void setUIBackend(const std::shared_ptr<UIBackend>& api)
|
||||
{
|
||||
getCurrentUIBackend() = api;
|
||||
}
|
||||
|
||||
bool setUIBackend(const std::string& backendName)
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
|
||||
std::string backendName_u = toUpperCase(backendName);
|
||||
if (g_initializedUIBackend)
|
||||
{
|
||||
// ... already initialized
|
||||
if (getUIBackendName() == backendName_u)
|
||||
{
|
||||
CV_LOG_INFO(NULL, "UI: backend is already activated: " << (backendName.empty() ? "builtin(legacy)" : backendName));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ... re-create new
|
||||
CV_LOG_DEBUG(NULL, "UI: replacing backend...");
|
||||
getUIBackendName() = backendName_u;
|
||||
getCurrentUIBackend() = createUIBackend();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ... no backend exists, just specify the name (initialization is triggered by getCurrentUIBackend() call)
|
||||
getUIBackendName() = backendName_u;
|
||||
}
|
||||
std::shared_ptr<UIBackend> api = getCurrentUIBackend();
|
||||
if (!api)
|
||||
{
|
||||
if (!backendName.empty())
|
||||
{
|
||||
CV_LOG_WARNING(NULL, "UI: backend is not available: " << backendName << " (using builtin legacy code)");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_LOG_WARNING(NULL, "UI: switched to builtin code (legacy)");
|
||||
}
|
||||
}
|
||||
if (!backendName_u.empty())
|
||||
{
|
||||
CV_Assert(backendName_u == getUIBackendName()); // data race?
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}} // namespace cv::highgui_backend
|
135
3rdparty/opencv-4.5.4/modules/highgui/src/backend.hpp
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#ifndef OPENCV_HIGHGUI_BACKEND_HPP
|
||||
#define OPENCV_HIGHGUI_BACKEND_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
namespace cv { namespace highgui_backend {
|
||||
|
||||
class CV_EXPORTS UIWindowBase
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<UIWindowBase> Ptr;
|
||||
typedef std::weak_ptr<UIWindowBase> WeakPtr;
|
||||
|
||||
virtual ~UIWindowBase();
|
||||
|
||||
virtual const std::string& getID() const = 0; // internal name, used for logging
|
||||
|
||||
virtual bool isActive() const = 0;
|
||||
|
||||
virtual void destroy() = 0;
|
||||
}; // UIWindowBase
|
||||
|
||||
class UITrackbar;
|
||||
|
||||
class CV_EXPORTS UIWindow : public UIWindowBase
|
||||
{
|
||||
public:
|
||||
virtual ~UIWindow();
|
||||
|
||||
virtual void imshow(InputArray image) = 0;
|
||||
|
||||
virtual double getProperty(int prop) const = 0;
|
||||
virtual bool setProperty(int prop, double value) = 0;
|
||||
|
||||
virtual void resize(int width, int height) = 0;
|
||||
virtual void move(int x, int y) = 0;
|
||||
|
||||
virtual Rect getImageRect() const = 0;
|
||||
|
||||
virtual void setTitle(const std::string& title) = 0;
|
||||
|
||||
virtual void setMouseCallback(MouseCallback onMouse, void* userdata /*= 0*/) = 0;
|
||||
|
||||
//TODO: handle both keys and mouse events (both with mouse coordinates)
|
||||
//virtual void setInputCallback(InputCallback onInputEvent, void* userdata /*= 0*/) = 0;
|
||||
|
||||
virtual std::shared_ptr<UITrackbar> createTrackbar(
|
||||
const std::string& name,
|
||||
int count,
|
||||
TrackbarCallback onChange /*= 0*/,
|
||||
void* userdata /*= 0*/
|
||||
) = 0;
|
||||
|
||||
virtual std::shared_ptr<UITrackbar> findTrackbar(const std::string& name) = 0;
|
||||
|
||||
#if 0 // QT only
|
||||
virtual void displayOverlay(const std::string& text, int delayms = 0) = 0;
|
||||
virtual void displayStatusBar(const std::string& text, int delayms /*= 0*/) = 0;
|
||||
virtual int createButton(
|
||||
const std::string& bar_name, ButtonCallback on_change,
|
||||
void* userdata = 0, int type /*= QT_PUSH_BUTTON*/,
|
||||
bool initial_button_state /*= false*/
|
||||
) = 0;
|
||||
// addText, QtFont stuff
|
||||
#endif
|
||||
|
||||
#if 0 // OpenGL
|
||||
virtual void imshow(const ogl::Texture2D& tex) = 0;
|
||||
virtual void setOpenGlDrawCallback(OpenGlDrawCallback onOpenGlDraw, void* userdata = 0) = 0;
|
||||
virtual void setOpenGlContext() = 0;
|
||||
virtual void updateWindow() = 0;
|
||||
#endif
|
||||
|
||||
}; // UIWindow
|
||||
|
||||
|
||||
class CV_EXPORTS UITrackbar : public UIWindowBase
|
||||
{
|
||||
public:
|
||||
virtual ~UITrackbar();
|
||||
|
||||
virtual int getPos() const = 0;
|
||||
virtual void setPos(int pos) = 0;
|
||||
|
||||
virtual cv::Range getRange() const = 0;
|
||||
virtual void setRange(const cv::Range& range) = 0;
|
||||
}; // UITrackbar
|
||||
|
||||
|
||||
class CV_EXPORTS UIBackend
|
||||
{
|
||||
public:
|
||||
virtual ~UIBackend();
|
||||
|
||||
virtual void destroyAllWindows() = 0;
|
||||
|
||||
// namedWindow
|
||||
virtual std::shared_ptr<UIWindow> createWindow(
|
||||
const std::string& winname,
|
||||
int flags
|
||||
) = 0;
|
||||
|
||||
virtual int waitKeyEx(int delay /*= 0*/) = 0;
|
||||
virtual int pollKey() = 0;
|
||||
};
|
||||
|
||||
std::shared_ptr<UIBackend>& getCurrentUIBackend();
|
||||
void setUIBackend(const std::shared_ptr<UIBackend>& api);
|
||||
bool setUIBackend(const std::string& backendName);
|
||||
|
||||
#ifndef BUILD_PLUGIN
|
||||
|
||||
#ifdef HAVE_WIN32UI
|
||||
std::shared_ptr<UIBackend> createUIBackendWin32UI();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GTK
|
||||
std::shared_ptr<UIBackend> createUIBackendGTK();
|
||||
#endif
|
||||
|
||||
#if 0 // TODO: defined HAVE_QT
|
||||
std::shared_ptr<UIBackend> createUIBackendQT();
|
||||
#endif
|
||||
|
||||
#endif // BUILD_PLUGIN
|
||||
|
||||
} // namespace highgui_backend
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_HIGHGUI_BACKEND_HPP
|
48
3rdparty/opencv-4.5.4/modules/highgui/src/factory.hpp
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_UI_FACTORY_HPP
|
||||
#define OPENCV_UI_FACTORY_HPP
|
||||
|
||||
#include "backend.hpp"
|
||||
|
||||
namespace cv { namespace highgui_backend {
|
||||
|
||||
class IUIBackendFactory
|
||||
{
|
||||
public:
|
||||
virtual ~IUIBackendFactory() {}
|
||||
virtual std::shared_ptr<cv::highgui_backend::UIBackend> create() const = 0;
|
||||
};
|
||||
|
||||
|
||||
class StaticBackendFactory CV_FINAL: public IUIBackendFactory
|
||||
{
|
||||
protected:
|
||||
std::function<std::shared_ptr<cv::highgui_backend::UIBackend>(void)> create_fn_;
|
||||
|
||||
public:
|
||||
StaticBackendFactory(std::function<std::shared_ptr<cv::highgui_backend::UIBackend>(void)>&& create_fn)
|
||||
: create_fn_(create_fn)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
~StaticBackendFactory() CV_OVERRIDE {}
|
||||
|
||||
std::shared_ptr<cv::highgui_backend::UIBackend> create() const CV_OVERRIDE
|
||||
{
|
||||
return create_fn_();
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// PluginUIBackendFactory is implemented in plugin_wrapper
|
||||
//
|
||||
|
||||
std::shared_ptr<IUIBackendFactory> createPluginUIBackendFactory(const std::string& baseName);
|
||||
|
||||
}} // namespace
|
||||
|
||||
#endif // OPENCV_UI_FACTORY_HPP
|
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/1.png
vendored
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/10.png
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/100.png
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/101.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/102.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/103.png
vendored
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/104.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/105.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/106.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/107.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/108.png
vendored
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/109.png
vendored
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/11.png
vendored
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/110.png
vendored
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/111.png
vendored
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/112.png
vendored
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/113.png
vendored
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/114.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/115.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/116.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/117.png
vendored
Normal file
After Width: | Height: | Size: 831 B |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/118.png
vendored
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/119.png
vendored
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/12.png
vendored
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/120.png
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/121.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/122.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/123.png
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/124.png
vendored
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/125.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/126.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/127.png
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/128.png
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/129.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/13.png
vendored
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/130.png
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/131.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/14.png
vendored
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/15.png
vendored
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/16.png
vendored
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/17.png
vendored
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/18.png
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/19.png
vendored
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/2.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/20.png
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/21.png
vendored
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/22.png
vendored
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/23.png
vendored
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/24.png
vendored
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/25.png
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/26.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/27.png
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/28.png
vendored
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/29.png
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/3.png
vendored
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/30.png
vendored
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/31.png
vendored
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/32.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/33.png
vendored
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/34.png
vendored
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/35.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/36.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/37.png
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/38.png
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/39.png
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/4.png
vendored
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/40.png
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/41.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/42.png
vendored
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/43.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/44.png
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/45.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/46.png
vendored
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/47.png
vendored
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/48.png
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/49.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/5.png
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/50.png
vendored
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
3rdparty/opencv-4.5.4/modules/highgui/src/files_Qt/Milky/48/51.png
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |