Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
993416d9
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 10 个月
通知
995
Star
71100
Fork
55580
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
993416d9
编写于
6月 07, 2021
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20229 from alalek:fix_highgui_build
上级
3e513ee6
327109f3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
127 addition
and
41 deletion
+127
-41
modules/highgui/CMakeLists.txt
modules/highgui/CMakeLists.txt
+34
-22
modules/highgui/cmake/detect_gtk.cmake
modules/highgui/cmake/detect_gtk.cmake
+11
-2
modules/highgui/cmake/init.cmake
modules/highgui/cmake/init.cmake
+27
-0
modules/highgui/misc/plugins/build_plugins.sh
modules/highgui/misc/plugins/build_plugins.sh
+7
-4
modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt
modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt
+15
-5
modules/highgui/misc/plugins/plugin_gtk/Dockerfile-ubuntu-gtk2
...es/highgui/misc/plugins/plugin_gtk/Dockerfile-ubuntu-gtk2
+7
-0
modules/highgui/misc/plugins/plugin_gtk/build.sh
modules/highgui/misc/plugins/plugin_gtk/build.sh
+11
-3
modules/highgui/src/backend.cpp
modules/highgui/src/backend.cpp
+2
-1
modules/highgui/src/registry.impl.hpp
modules/highgui/src/registry.impl.hpp
+1
-0
modules/highgui/src/window_gtk.cpp
modules/highgui/src/window_gtk.cpp
+12
-4
未找到文件。
modules/highgui/CMakeLists.txt
浏览文件 @
993416d9
set
(
the_description
"High-level GUI"
)
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
()
if
(
ANDROID
)
ocv_add_module
(
highgui opencv_imgproc opencv_imgcodecs OPTIONAL opencv_videoio WRAP python
)
else
()
...
...
@@ -68,7 +47,10 @@ file(GLOB highgui_ext_hdrs
# 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_QT5
)
set
(
OPENCV_HIGHGUI_BUILTIN_BACKEND
"QT5"
)
add_definitions
(
-DHAVE_QT
)
# "Automoc" doesn't work properly with opencv_world build, use QT5_WRAP_CPP() directly
...
...
@@ -96,8 +78,8 @@ if(HAVE_QT5)
include_directories
(
${
Qt5OpenGL_INCLUDE_DIRS
}
)
list
(
APPEND HIGHGUI_LIBRARIES
${
Qt5OpenGL_LIBRARIES
}
)
endif
()
elseif
(
HAVE_QT
)
set
(
OPENCV_HIGHGUI_BUILTIN_BACKEND
"QT4"
)
add_definitions
(
-DHAVE_QT
)
if
(
HAVE_QT_OPENGL
)
add_definitions
(
-DHAVE_QT_OPENGL
)
...
...
@@ -115,6 +97,7 @@ elseif(HAVE_QT)
set_source_files_properties
(
${
_RCC_OUTFILES
}
PROPERTIES COMPILE_FLAGS -Wno-missing-declarations
)
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.
...
...
@@ -149,11 +132,13 @@ elseif(WINRT)
message
(
STATUS
"
${
name
}
: Leaving '
${
HIGHGUI_LIBRARIES
}
'"
)
endif
()
elseif
(
HAVE_WIN32UI
)
set
(
OPENCV_HIGHGUI_BUILTIN_BACKEND
"WIN32UI"
)
list
(
APPEND highgui_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/src/window_w32.cpp
)
if
(
OpenCV_ARCH STREQUAL
"ARM64"
)
list
(
APPEND HIGHGUI_LIBRARIES
"comdlg32"
"advapi32"
)
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"
)
...
...
@@ -170,16 +155,31 @@ if(TARGET ocv.3rdparty.gtk3 OR TARGET ocv.3rdparty.gtk2)
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"
)
...
...
@@ -211,6 +211,11 @@ if(TARGET ocv.3rdparty.gtk3 OR TARGET ocv.3rdparty.gtk2)
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
}
"
)
# FIXIT: propagate to root CMake
if
(
TRUE
)
# these variables are set by 'ocv_append_build_options(HIGHGUI ...)'
foreach
(
P
${
HIGHGUI_INCLUDE_DIRS
}
)
...
...
@@ -271,3 +276,10 @@ if(HIGHGUI_ENABLE_PLUGINS)
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
}
\"
"
)
ocv_update_file
(
"
${
CMAKE_CURRENT_BINARY_DIR
}
/opencv_highgui_config.hpp"
"
${
CONFIG_STR
}
"
)
modules/highgui/cmake/detect_gtk.cmake
浏览文件 @
993416d9
# --- GTK ---
ocv_clear_vars
(
HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT
)
ocv_clear_vars
(
HAVE_GTK HAVE_GTK
2 HAVE_GTK
3 HAVE_GTHREAD HAVE_GTKGLEXT
)
if
(
WITH_GTK
)
if
(
NOT WITH_GTK_2_X
)
ocv_check_modules
(
GTK3 gtk+-3.0
)
...
...
@@ -32,7 +32,7 @@ if(WITH_GTK)
set
(
HAVE_GTHREAD
"
${
HAVE_GTHREAD
}
"
PARENT_SCOPE
)
# informational
set
(
GTHREAD_VERSION
"
${
GTHREAD_VERSION
}
"
PARENT_SCOPE
)
# informational
endif
()
if
(
WITH_OPENGL AND NOT HAVE_GTK3
)
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"
)
...
...
@@ -44,4 +44,13 @@ 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
)
#set(HAVE_OPENGL ${HAVE_OPENGL} PARENT_SCOPE)
ocv_add_external_target
(
gtk_opengl
"
${
OPENGL_INCLUDE_DIRS
}
"
"
${
OPENGL_LIBRARIES
}
"
"HAVE_OPENGL"
)
endif
()
endif
()
set
(
HAVE_GTK
${
HAVE_GTK
}
PARENT_SCOPE
)
modules/highgui/cmake/init.cmake
浏览文件 @
993416d9
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
#
include
(
FindPkgConfig
)
# FIXIT: stop using PARENT_SCOPE in dependencies
...
...
modules/highgui/misc/plugins/build_plugins.sh
浏览文件 @
993416d9
...
...
@@ -11,7 +11,7 @@ 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
CFG
=
$
{
2
:-
Release
}
do_build
()
{
...
...
@@ -40,30 +40,33 @@ docker run \
-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
}
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
}
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
modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt
浏览文件 @
993416d9
...
...
@@ -25,6 +25,21 @@ 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
}
"
)
...
...
@@ -41,8 +56,3 @@ if(HAVE_GTHREAD)
else
()
message
(
STATUS
"GThread : NO"
)
endif
()
if
(
HAVE_GTKGLEXT
)
message
(
STATUS
"GtkGlExt: YES (ver
${
GTKGLEXT_VERSION
}
)"
)
else
()
message
(
STATUS
"GtkGlExt: NO"
)
endif
()
modules/highgui/misc/plugins/plugin_gtk/Dockerfile-ubuntu-gtk2
浏览文件 @
993416d9
...
...
@@ -18,4 +18,11 @@ RUN \
&& \
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
modules/highgui/misc/plugins/plugin_gtk/build.sh
浏览文件 @
993416d9
...
...
@@ -4,10 +4,18 @@ 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_highgui_
$2
\
-DOPENCV_PLUGIN_DESTINATION
=
$1
\
-DCMAKE_BUILD_TYPE
=
$3
\
-DOPENCV_PLUGIN_NAME
=
${
OPENCV_PLUGIN_NAME
}
\
-DOPENCV_PLUGIN_DESTINATION
=
${
OPENCV_PLUGIN_DESTINATION
}
\
-DCMAKE_BUILD_TYPE
=
${
CMAKE_BUILD_TYPE
}
\
"
$@
"
\
$DIR
ninja
-v
modules/highgui/src/backend.cpp
浏览文件 @
993416d9
...
...
@@ -2,6 +2,7 @@
// 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 "opencv_highgui_config.hpp" // generated by CMake
#include "backend.hpp"
#include <opencv2/core/utils/configuration.private.hpp>
...
...
@@ -103,7 +104,7 @@ std::shared_ptr<UIBackend> createUIBackend()
}
if
(
name
.
empty
())
{
CV_LOG_DEBUG
(
NULL
,
"UI: fallback on builtin code
"
);
CV_LOG_DEBUG
(
NULL
,
"UI: fallback on builtin code
: "
OPENCV_HIGHGUI_BUILTIN_BACKEND_STR
);
}
else
{
...
...
modules/highgui/src/registry.impl.hpp
浏览文件 @
993416d9
...
...
@@ -162,6 +162,7 @@ public:
const
BackendInfo
&
info
=
enabledBackends
[
i
];
os
<<
info
.
name
<<
'('
<<
info
.
priority
<<
')'
;
}
os
<<
" + BUILTIN("
OPENCV_HIGHGUI_BUILTIN_BACKEND_STR
")"
;
return
os
.
str
();
}
...
...
modules/highgui/src/window_gtk.cpp
浏览文件 @
993416d9
...
...
@@ -45,6 +45,14 @@
#if defined (HAVE_GTK)
#include <gtk/gtk.h>
#if (GTK_MAJOR_VERSION == 3) && defined(HAVE_OPENGL)
#undef HAVE_OPENGL // no support with GTK3
#endif
#if defined(HAVE_OPENGL) && !defined(HAVE_GTKGLEXT)
#undef HAVE_OPENGL // gtkglext is required
#endif
#include <gdk/gdkkeysyms.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <stdio.h>
...
...
@@ -1187,7 +1195,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
#ifdef HAVE_OPENGL
if
(
window
->
useGl
)
cvSetOpenGlContext
(
name
);
cvSetOpenGlContext
(
name
.
c_str
()
);
#endif
return
window_ptr
;
...
...
@@ -1205,7 +1213,7 @@ CV_IMPL void cvSetOpenGlContext(const char* name)
CV_LOCK_MUTEX
();
CvWindow
*
window
=
icvFindWindowByName
(
name
);
auto
window
=
icvFindWindowByName
(
name
);
if
(
!
window
)
CV_Error
(
CV_StsNullPtr
,
"NULL window"
);
...
...
@@ -1225,7 +1233,7 @@ CV_IMPL void cvUpdateWindow(const char* name)
CV_LOCK_MUTEX
();
CvWindow
*
window
=
icvFindWindowByName
(
name
);
auto
window
=
icvFindWindowByName
(
name
);
if
(
!
window
)
return
;
...
...
@@ -1239,7 +1247,7 @@ CV_IMPL void cvSetOpenGlDrawCallback(const char* name, CvOpenGlDrawCallback call
CV_LOCK_MUTEX
();
CvWindow
*
window
=
icvFindWindowByName
(
name
);
auto
window
=
icvFindWindowByName
(
name
);
if
(
!
window
)
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录