Skip to content

Commit 87d4970

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 4938765 + b1a772d commit 87d4970

File tree

9 files changed

+299
-117
lines changed

9 files changed

+299
-117
lines changed

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,12 +1247,17 @@ status("")
12471247
status(" GUI: " "${OPENCV_HIGHGUI_BUILTIN_BACKEND}")
12481248

12491249
if(WITH_QT OR HAVE_QT)
1250-
if(HAVE_QT5)
1251-
status(" QT:" "YES (ver ${Qt5Core_VERSION_STRING})")
1252-
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt5OpenGL_LIBRARIES} ${Qt5OpenGL_VERSION_STRING})" ELSE NO)
1253-
elseif(HAVE_QT)
1250+
if(HAVE_QT)
12541251
status(" QT:" "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})")
1255-
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
1252+
if(HAVE_QT_OPENGL)
1253+
if(Qt${QT_VERSION_MAJOR}OpenGL_LIBRARIES)
1254+
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt${QT_VERSION_MAJOR}OpenGL_LIBRARIES} ${Qt${QT_VERSION_MAJOR}OpenGL_VERSION_STRING})" ELSE NO)
1255+
else()
1256+
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
1257+
endif()
1258+
else()
1259+
status(" QT OpenGL support:" "NO")
1260+
endif()
12561261
else()
12571262
status(" QT:" "NO")
12581263
endif()

cmake/OpenCVDetectVTK.cmake

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,15 @@ if(VTK_VERSION VERSION_LESS "5.8.0")
4444
endif()
4545

4646
# Different Qt versions can't be linked together
47-
if(HAVE_QT5 AND VTK_VERSION VERSION_LESS "6.0.0")
48-
if(VTK_USE_QT)
49-
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
50-
endif()
51-
endif()
52-
53-
# Different Qt versions can't be linked together. VTK 6.0.0 doesn't provide a way to get Qt version it was linked with
54-
if(HAVE_QT5 AND VTK_VERSION VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK)
55-
message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt5, and VTK ver.${VTK_VERSION} with Qt4")
56-
message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DFORCE_VTK=TRUE' flag in CMake")
47+
if((HAVE_QT AND VTK_USE_QT)
48+
AND NOT DEFINED FORCE_VTK # deprecated
49+
AND NOT DEFINED OPENCV_FORCE_VTK
50+
)
51+
message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt, and VTK ver.${VTK_VERSION} with Qt")
52+
message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DOPENCV_FORCE_VTK=TRUE' flag in CMake")
5753
return()
5854
endif()
5955

60-
# Different Qt versions can't be linked together
61-
if(HAVE_QT AND VTK_VERSION VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "")
62-
if(HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "4")
63-
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
64-
return()
65-
endif()
66-
67-
if(NOT HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "5")
68-
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt4 and VTK ver.${VTK_VERSION} + Qt5")
69-
return()
70-
endif()
71-
endif()
72-
7356
try_compile(VTK_COMPILE_STATUS
7457
"${OpenCV_BINARY_DIR}"
7558
"${OpenCV_SOURCE_DIR}/cmake/checks/vtk_test.cpp"

cmake/OpenCVFindLibsGUI.cmake

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,50 @@
44

55
# --- QT4/5 ---
66
ocv_clear_vars(HAVE_QT HAVE_QT5)
7+
8+
macro(ocv_find_package_Qt4)
9+
find_package(Qt4 COMPONENTS QtCore QtGui QtTest ${ARGN})
10+
if(QT4_FOUND)
11+
set(QT_FOUND 1)
12+
ocv_assert(QT_VERSION_MAJOR EQUAL 4)
13+
endif()
14+
endmacro()
15+
16+
macro(ocv_find_package_Qt OCV_QT_VER)
17+
find_package(Qt${OCV_QT_VER} COMPONENTS Core Gui Widgets Test Concurrent ${ARGN} NO_MODULE)
18+
if(Qt${OCV_QT_VER}_FOUND)
19+
set(QT_FOUND 1)
20+
set(QT_VERSION "${Qt${OCV_QT_VER}_VERSION}")
21+
set(QT_VERSION_MAJOR "${Qt${OCV_QT_VER}_VERSION_MAJOR}")
22+
set(QT_VERSION_MINOR "${Qt${OCV_QT_VER}_VERSION_MINOR}")
23+
set(QT_VERSION_PATCH "${Qt${OCV_QT_VER}_VERSION_PATCH}")
24+
set(QT_VERSION_TWEAK "${Qt${OCV_QT_VER}_VERSION_TWEAK}")
25+
set(QT_VERSION_COUNT "${Qt${OCV_QT_VER}_VERSION_COUNT}")
26+
endif()
27+
endmacro()
28+
729
if(WITH_QT)
8-
if(NOT WITH_QT EQUAL 4)
9-
find_package(Qt5 COMPONENTS Core Gui Widgets Test Concurrent REQUIRED NO_MODULE)
10-
if(Qt5_FOUND)
11-
set(HAVE_QT5 ON)
12-
set(HAVE_QT ON)
13-
find_package(Qt5 COMPONENTS OpenGL QUIET)
14-
if(Qt5OpenGL_FOUND)
15-
set(QT_QTOPENGL_FOUND ON)
16-
endif()
30+
if(NOT WITH_QT GREATER 0)
31+
# BUG: Qt5Config.cmake script can't handle components properly: find_package(QT NAMES Qt6 Qt5 REQUIRED NO_MODULE COMPONENTS Core Gui Widgets Test Concurrent)
32+
ocv_find_package_Qt(6 QUIET)
33+
if(NOT QT_FOUND)
34+
ocv_find_package_Qt(5 QUIET)
35+
endif()
36+
if(NOT QT_FOUND)
37+
ocv_find_package_Qt4(QUIET)
1738
endif()
39+
elseif(WITH_QT EQUAL 4)
40+
ocv_find_package_Qt4(REQUIRED)
41+
else() # WITH_QT=<major version>
42+
ocv_find_package_Qt("${WITH_QT}" REQUIRED)
1843
endif()
19-
20-
if(NOT HAVE_QT)
21-
find_package(Qt4 REQUIRED QtCore QtGui QtTest)
22-
if(QT4_FOUND)
23-
set(HAVE_QT TRUE)
44+
if(QT_FOUND)
45+
set(HAVE_QT ON)
46+
if(QT_VERSION_MAJOR GREATER 4)
47+
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGL QUIET)
48+
if(Qt${QT_VERSION_MAJOR}OpenGL_FOUND)
49+
set(QT_QTOPENGL_FOUND ON) # HAVE_QT_OPENGL is defined below
50+
endif()
2451
endif()
2552
endif()
2653
endif()

modules/core/src/parallel_impl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,11 @@ void ThreadPool::run(const Range& range, const ParallelLoopBody& body, double ns
580580
{
581581
WorkerThread& thread = *(threads[i].get());
582582
if (
583+
#if defined(__clang__) && defined(__has_feature)
584+
#if __has_feature(thread_sanitizer)
585+
1 || // Robust workaround to avoid data race warning of `thread.job`
586+
#endif
587+
#endif
583588
#if !defined(CV_USE_GLOBAL_WORKERS_COND_VAR)
584589
thread.isActive ||
585590
#endif

modules/highgui/CMakeLists.txt

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,52 +49,56 @@ list(REMOVE_ITEM highgui_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${n
4949

5050
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "")
5151

52-
if(HAVE_QT5)
53-
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "QT5")
54-
add_definitions(-DHAVE_QT)
55-
56-
# "Automoc" doesn't work properly with opencv_world build, use QT5_WRAP_CPP() directly
57-
#set(CMAKE_AUTOMOC ON)
58-
59-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
60-
61-
QT5_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
62-
QT5_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
63-
list(APPEND highgui_srcs
64-
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp
65-
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h
66-
${_MOC_OUTFILES}
67-
${_RCC_OUTFILES})
68-
69-
foreach(dt5_dep Core Gui Widgets Test Concurrent)
70-
add_definitions(${Qt5${dt5_dep}_DEFINITIONS})
71-
include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS})
72-
list(APPEND HIGHGUI_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES})
73-
endforeach()
52+
if(HAVE_QT)
53+
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "QT${QT_VERSION_MAJOR}")
54+
if(QT_VERSION_MAJOR GREATER 4)
55+
# "Automoc" doesn't work properly with opencv_world build, use QT<ver>_WRAP_CPP() directly
56+
#set(CMAKE_AUTOMOC ON)
57+
58+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
59+
60+
if(QT_VERSION_MAJOR EQUAL 6)
61+
QT6_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
62+
QT6_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
63+
elseif(QT_VERSION_MAJOR EQUAL 5)
64+
QT5_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
65+
QT5_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
66+
else()
67+
message(FATAL_ERROR "Unsuported QT version: ${QT_VERSION_MAJOR}")
68+
endif()
7469

75-
if(HAVE_QT_OPENGL)
76-
add_definitions(-DHAVE_QT_OPENGL)
77-
add_definitions(${Qt5OpenGL_DEFINITIONS})
78-
include_directories(${Qt5OpenGL_INCLUDE_DIRS})
79-
list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES})
80-
endif()
81-
elseif(HAVE_QT)
82-
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "QT4")
83-
add_definitions(-DHAVE_QT)
84-
if(HAVE_QT_OPENGL)
85-
add_definitions(-DHAVE_QT_OPENGL)
86-
set(QT_USE_QTOPENGL TRUE)
87-
endif()
88-
include(${QT_USE_FILE})
70+
list(APPEND highgui_srcs
71+
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp
72+
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h
73+
${_MOC_OUTFILES}
74+
${_RCC_OUTFILES})
75+
76+
set(qt_deps Core Gui Widgets Test Concurrent)
77+
if(HAVE_QT_OPENGL)
78+
list(APPEND qt_deps OpenGL)
79+
endif()
8980

90-
QT4_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
91-
QT4_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
81+
foreach(dt_dep ${qt_deps})
82+
add_definitions(${Qt${QT_VERSION_MAJOR}${dt_dep}_DEFINITIONS})
83+
include_directories(${Qt${QT_VERSION_MAJOR}${dt_dep}_INCLUDE_DIRS})
84+
list(APPEND HIGHGUI_LIBRARIES ${Qt${QT_VERSION_MAJOR}${dt_dep}_LIBRARIES})
85+
endforeach()
86+
else()
87+
ocv_assert(QT_VERSION_MAJOR EQUAL 4)
88+
if (HAVE_QT_OPENGL)
89+
set(QT_USE_QTOPENGL TRUE)
90+
endif()
91+
include(${QT_USE_FILE})
9292

93-
list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES})
94-
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES})
95-
ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag "")
96-
if(${_have_flag})
97-
set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
93+
QT4_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
94+
QT4_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
95+
96+
list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES})
97+
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES})
98+
ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag "")
99+
if(${_have_flag})
100+
set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
101+
endif()
98102
endif()
99103
elseif(WINRT)
100104
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "WINRT")

modules/highgui/src/window_QT.cpp

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,38 @@
6565

6666
using namespace cv;
6767

68+
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
69+
#define Qt_MiddleButton Qt::MiddleButton
70+
inline Qt::Orientation wheelEventOrientation(QWheelEvent *we) {
71+
if (std::abs(we->angleDelta().x()) < std::abs(we->angleDelta().y()))
72+
return Qt::Vertical;
73+
else
74+
return Qt::Horizontal;
75+
}
76+
inline int wheelEventDelta(QWheelEvent *we) {
77+
if(wheelEventOrientation(we) == Qt::Vertical)
78+
return we->angleDelta().y();
79+
else
80+
return we->angleDelta().x();
81+
}
82+
inline QPoint wheelEventPos(QWheelEvent *we) {
83+
return we->position().toPoint();
84+
}
85+
#else
86+
#define Qt_MiddleButton Qt::MidButton
87+
inline Qt::Orientation wheelEventOrientation(QWheelEvent *we) {
88+
return we->orientation();
89+
}
90+
inline int wheelEventDelta(QWheelEvent *we) {
91+
return we->delta();
92+
}
93+
inline QPoint wheelEventPos(QWheelEvent *we) {
94+
return we->pos();
95+
}
96+
97+
#endif
98+
99+
68100
//Static and global first
69101
static GuiReceiver *guiMainThread = NULL;
70102
static int parameterSystemC = 1;
@@ -1580,7 +1612,9 @@ CvWinProperties::CvWinProperties(QString name_paraWindow, QObject* /*parent*/)
15801612
myLayout->setObjectName(QString::fromUtf8("boxLayout"));
15811613
myLayout->setContentsMargins(0, 0, 0, 0);
15821614
myLayout->setSpacing(0);
1615+
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
15831616
myLayout->setMargin(0);
1617+
#endif
15841618
myLayout->setSizeConstraint(QLayout::SetFixedSize);
15851619
setLayout(myLayout);
15861620

@@ -1958,7 +1992,9 @@ void CvWindow::createBarLayout()
19581992
myBarLayout->setObjectName(QString::fromUtf8("barLayout"));
19591993
myBarLayout->setContentsMargins(0, 0, 0, 0);
19601994
myBarLayout->setSpacing(0);
1995+
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
19611996
myBarLayout->setMargin(0);
1997+
#endif
19621998
}
19631999

19642000

@@ -1968,7 +2004,9 @@ void CvWindow::createGlobalLayout()
19682004
myGlobalLayout->setObjectName(QString::fromUtf8("boxLayout"));
19692005
myGlobalLayout->setContentsMargins(0, 0, 0, 0);
19702006
myGlobalLayout->setSpacing(0);
2007+
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
19712008
myGlobalLayout->setMargin(0);
2009+
#endif
19722010
setMinimumSize(1, 1);
19732011

19742012
if (param_flags == CV_WINDOW_AUTOSIZE)
@@ -2206,7 +2244,7 @@ void CvWindow::icvLoadControlPanel()
22062244
}
22072245
if (t->type == type_CvButtonbar)
22082246
{
2209-
int subsize = settings.beginReadArray(QString("buttonbar")+i);
2247+
int subsize = settings.beginReadArray(QString("buttonbar%1").arg(i));
22102248

22112249
if ( subsize == ((CvButtonbar*)t)->layout()->count() )
22122250
icvLoadButtonbar((CvButtonbar*)t,&settings);
@@ -2237,7 +2275,7 @@ void CvWindow::icvSaveControlPanel()
22372275
}
22382276
if (t->type == type_CvButtonbar)
22392277
{
2240-
settings.beginWriteArray(QString("buttonbar")+i);
2278+
settings.beginWriteArray(QString("buttonbar%1").arg(i));
22412279
icvSaveButtonbar((CvButtonbar*)t,&settings);
22422280
settings.endArray();
22432281
}
@@ -2397,14 +2435,14 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
23972435
flags |= CV_EVENT_FLAG_LBUTTON;
23982436
if(buttons & Qt::RightButton)
23992437
flags |= CV_EVENT_FLAG_RBUTTON;
2400-
if(buttons & Qt::MidButton)
2438+
if(buttons & Qt_MiddleButton)
24012439
flags |= CV_EVENT_FLAG_MBUTTON;
24022440

24032441
if (cv_event == -1) {
24042442
if (category == mouse_wheel) {
24052443
QWheelEvent *we = (QWheelEvent *) evnt;
2406-
cv_event = ((we->orientation() == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
2407-
flags |= (we->delta() & 0xffff)<<16;
2444+
cv_event = ((wheelEventOrientation(we) == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
2445+
flags |= (wheelEventDelta(we) & 0xffff)<<16;
24082446
return;
24092447
}
24102448
switch(evnt->button())
@@ -2417,7 +2455,7 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
24172455
cv_event = tableMouseButtons[category][1];
24182456
flags |= CV_EVENT_FLAG_RBUTTON;
24192457
break;
2420-
case Qt::MidButton:
2458+
case Qt_MiddleButton:
24212459
cv_event = tableMouseButtons[category][2];
24222460
flags |= CV_EVENT_FLAG_MBUTTON;
24232461
break;
@@ -2772,7 +2810,7 @@ void DefaultViewPort::wheelEvent(QWheelEvent* evnt)
27722810
{
27732811
icvmouseEvent((QMouseEvent *)evnt, mouse_wheel);
27742812

2775-
scaleView(evnt->delta() / 240.0, evnt->pos());
2813+
scaleView(wheelEventDelta(evnt) / 240.0, wheelEventPos(evnt));
27762814
viewport()->update();
27772815

27782816
QWidget::wheelEvent(evnt);

modules/js/generator/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ add_custom_command(
6060
${JS_SOURCE_DIR}/src/core_bindings.cpp
6161
${CMAKE_CURRENT_SOURCE_DIR}/embindgen.py
6262
${CMAKE_CURRENT_SOURCE_DIR}/templates.py
63+
"${OPENCV_JS_WHITELIST_FILE}"
6364
${scripts_hdr_parser}
6465
#(not needed - generated by CMake) ${CMAKE_CURRENT_BINARY_DIR}/headers.txt
6566
${opencv_hdrs}

0 commit comments

Comments
 (0)