mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -580,6 +580,11 @@ void ThreadPool::run(const Range& range, const ParallelLoopBody& body, double ns
|
||||
{
|
||||
WorkerThread& thread = *(threads[i].get());
|
||||
if (
|
||||
#if defined(__clang__) && defined(__has_feature)
|
||||
#if __has_feature(thread_sanitizer)
|
||||
1 || // Robust workaround to avoid data race warning of `thread.job`
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(CV_USE_GLOBAL_WORKERS_COND_VAR)
|
||||
thread.isActive ||
|
||||
#endif
|
||||
|
||||
@@ -49,52 +49,56 @@ list(REMOVE_ITEM highgui_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${n
|
||||
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "")
|
||||
|
||||
if(HAVE_QT5)
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "QT5")
|
||||
add_definitions(-DHAVE_QT)
|
||||
if(HAVE_QT)
|
||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "QT${QT_VERSION_MAJOR}")
|
||||
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)
|
||||
|
||||
# "Automoc" doesn't work properly with opencv_world build, use QT5_WRAP_CPP() directly
|
||||
#set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR 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()
|
||||
|
||||
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)
|
||||
list(APPEND highgui_srcs
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h
|
||||
${_MOC_OUTFILES}
|
||||
${_RCC_OUTFILES})
|
||||
list(APPEND highgui_srcs
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h
|
||||
${_MOC_OUTFILES}
|
||||
${_RCC_OUTFILES})
|
||||
|
||||
foreach(dt5_dep Core Gui Widgets Test Concurrent)
|
||||
add_definitions(${Qt5${dt5_dep}_DEFINITIONS})
|
||||
include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES})
|
||||
endforeach()
|
||||
set(qt_deps Core Gui Widgets Test Concurrent)
|
||||
if(HAVE_QT_OPENGL)
|
||||
list(APPEND qt_deps OpenGL)
|
||||
endif()
|
||||
|
||||
if(HAVE_QT_OPENGL)
|
||||
add_definitions(-DHAVE_QT_OPENGL)
|
||||
add_definitions(${Qt5OpenGL_DEFINITIONS})
|
||||
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)
|
||||
set(QT_USE_QTOPENGL TRUE)
|
||||
endif()
|
||||
include(${QT_USE_FILE})
|
||||
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)
|
||||
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)
|
||||
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")
|
||||
|
||||
@@ -65,6 +65,38 @@
|
||||
|
||||
using namespace cv;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
#define Qt_MiddleButton Qt::MiddleButton
|
||||
inline Qt::Orientation wheelEventOrientation(QWheelEvent *we) {
|
||||
if (std::abs(we->angleDelta().x()) < std::abs(we->angleDelta().y()))
|
||||
return Qt::Vertical;
|
||||
else
|
||||
return Qt::Horizontal;
|
||||
}
|
||||
inline int wheelEventDelta(QWheelEvent *we) {
|
||||
if(wheelEventOrientation(we) == Qt::Vertical)
|
||||
return we->angleDelta().y();
|
||||
else
|
||||
return we->angleDelta().x();
|
||||
}
|
||||
inline QPoint wheelEventPos(QWheelEvent *we) {
|
||||
return we->position().toPoint();
|
||||
}
|
||||
#else
|
||||
#define Qt_MiddleButton Qt::MidButton
|
||||
inline Qt::Orientation wheelEventOrientation(QWheelEvent *we) {
|
||||
return we->orientation();
|
||||
}
|
||||
inline int wheelEventDelta(QWheelEvent *we) {
|
||||
return we->delta();
|
||||
}
|
||||
inline QPoint wheelEventPos(QWheelEvent *we) {
|
||||
return we->pos();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//Static and global first
|
||||
static GuiReceiver *guiMainThread = NULL;
|
||||
static int parameterSystemC = 1;
|
||||
@@ -1580,7 +1612,9 @@ CvWinProperties::CvWinProperties(QString name_paraWindow, QObject* /*parent*/)
|
||||
myLayout->setObjectName(QString::fromUtf8("boxLayout"));
|
||||
myLayout->setContentsMargins(0, 0, 0, 0);
|
||||
myLayout->setSpacing(0);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
myLayout->setMargin(0);
|
||||
#endif
|
||||
myLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setLayout(myLayout);
|
||||
|
||||
@@ -1958,7 +1992,9 @@ void CvWindow::createBarLayout()
|
||||
myBarLayout->setObjectName(QString::fromUtf8("barLayout"));
|
||||
myBarLayout->setContentsMargins(0, 0, 0, 0);
|
||||
myBarLayout->setSpacing(0);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
myBarLayout->setMargin(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1968,7 +2004,9 @@ void CvWindow::createGlobalLayout()
|
||||
myGlobalLayout->setObjectName(QString::fromUtf8("boxLayout"));
|
||||
myGlobalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
myGlobalLayout->setSpacing(0);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
myGlobalLayout->setMargin(0);
|
||||
#endif
|
||||
setMinimumSize(1, 1);
|
||||
|
||||
if (param_flags == CV_WINDOW_AUTOSIZE)
|
||||
@@ -2206,7 +2244,7 @@ void CvWindow::icvLoadControlPanel()
|
||||
}
|
||||
if (t->type == type_CvButtonbar)
|
||||
{
|
||||
int subsize = settings.beginReadArray(QString("buttonbar")+i);
|
||||
int subsize = settings.beginReadArray(QString("buttonbar%1").arg(i));
|
||||
|
||||
if ( subsize == ((CvButtonbar*)t)->layout()->count() )
|
||||
icvLoadButtonbar((CvButtonbar*)t,&settings);
|
||||
@@ -2237,7 +2275,7 @@ void CvWindow::icvSaveControlPanel()
|
||||
}
|
||||
if (t->type == type_CvButtonbar)
|
||||
{
|
||||
settings.beginWriteArray(QString("buttonbar")+i);
|
||||
settings.beginWriteArray(QString("buttonbar%1").arg(i));
|
||||
icvSaveButtonbar((CvButtonbar*)t,&settings);
|
||||
settings.endArray();
|
||||
}
|
||||
@@ -2397,14 +2435,14 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
|
||||
flags |= CV_EVENT_FLAG_LBUTTON;
|
||||
if(buttons & Qt::RightButton)
|
||||
flags |= CV_EVENT_FLAG_RBUTTON;
|
||||
if(buttons & Qt::MidButton)
|
||||
if(buttons & Qt_MiddleButton)
|
||||
flags |= CV_EVENT_FLAG_MBUTTON;
|
||||
|
||||
if (cv_event == -1) {
|
||||
if (category == mouse_wheel) {
|
||||
QWheelEvent *we = (QWheelEvent *) evnt;
|
||||
cv_event = ((we->orientation() == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
|
||||
flags |= (we->delta() & 0xffff)<<16;
|
||||
cv_event = ((wheelEventOrientation(we) == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
|
||||
flags |= (wheelEventDelta(we) & 0xffff)<<16;
|
||||
return;
|
||||
}
|
||||
switch(evnt->button())
|
||||
@@ -2417,7 +2455,7 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
|
||||
cv_event = tableMouseButtons[category][1];
|
||||
flags |= CV_EVENT_FLAG_RBUTTON;
|
||||
break;
|
||||
case Qt::MidButton:
|
||||
case Qt_MiddleButton:
|
||||
cv_event = tableMouseButtons[category][2];
|
||||
flags |= CV_EVENT_FLAG_MBUTTON;
|
||||
break;
|
||||
@@ -2772,7 +2810,7 @@ void DefaultViewPort::wheelEvent(QWheelEvent* evnt)
|
||||
{
|
||||
icvmouseEvent((QMouseEvent *)evnt, mouse_wheel);
|
||||
|
||||
scaleView(evnt->delta() / 240.0, evnt->pos());
|
||||
scaleView(wheelEventDelta(evnt) / 240.0, wheelEventPos(evnt));
|
||||
viewport()->update();
|
||||
|
||||
QWidget::wheelEvent(evnt);
|
||||
|
||||
@@ -60,6 +60,7 @@ add_custom_command(
|
||||
${JS_SOURCE_DIR}/src/core_bindings.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/embindgen.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/templates.py
|
||||
"${OPENCV_JS_WHITELIST_FILE}"
|
||||
${scripts_hdr_parser}
|
||||
#(not needed - generated by CMake) ${CMAKE_CURRENT_BINARY_DIR}/headers.txt
|
||||
${opencv_hdrs}
|
||||
|
||||
@@ -104,6 +104,10 @@ def makeWhiteList(module_list):
|
||||
return wl
|
||||
|
||||
white_list = None
|
||||
namespace_prefix_override = {
|
||||
'dnn' : '',
|
||||
'aruco' : '',
|
||||
}
|
||||
|
||||
# Features to be exported
|
||||
export_enums = False
|
||||
@@ -271,6 +275,8 @@ class FuncVariant(object):
|
||||
|
||||
class FuncInfo(object):
|
||||
def __init__(self, class_name, name, cname, namespace, isconstructor):
|
||||
self.name_id = '_'.join([namespace] + ([class_name] if class_name else []) + [name]) # unique id for dict key
|
||||
|
||||
self.class_name = class_name
|
||||
self.name = name
|
||||
self.cname = cname
|
||||
@@ -295,9 +301,9 @@ class JSWrapperGenerator(object):
|
||||
self.bindings = []
|
||||
self.wrapper_funcs = []
|
||||
|
||||
self.classes = {}
|
||||
self.classes = {} # FIXIT 'classes' should belong to 'namespaces'
|
||||
self.namespaces = {}
|
||||
self.enums = {}
|
||||
self.enums = {} # FIXIT 'enums' should belong to 'namespaces'
|
||||
|
||||
self.parser = hdr_parser.CppHeaderParser()
|
||||
self.class_idx = 0
|
||||
@@ -419,7 +425,8 @@ class JSWrapperGenerator(object):
|
||||
else:
|
||||
func_map = self.namespaces.setdefault(namespace, Namespace()).funcs
|
||||
|
||||
func = func_map.setdefault(name, FuncInfo(class_name, name, cpp_name, namespace, is_constructor))
|
||||
fi = FuncInfo(class_name, name, cpp_name, namespace, is_constructor)
|
||||
func = func_map.setdefault(fi.name_id, fi)
|
||||
|
||||
variant = FuncVariant(class_name, name, decl, is_constructor, is_class_method, is_const_method,
|
||||
is_virtual_method, is_pure_virtual_method, ref_return, const_return)
|
||||
@@ -430,7 +437,7 @@ class JSWrapperGenerator(object):
|
||||
f.write(buf.getvalue())
|
||||
f.close()
|
||||
|
||||
def gen_function_binding_with_wrapper(self, func, class_info):
|
||||
def gen_function_binding_with_wrapper(self, func, ns_name, class_info):
|
||||
|
||||
binding_text = None
|
||||
wrapper_func_text = None
|
||||
@@ -488,8 +495,23 @@ class JSWrapperGenerator(object):
|
||||
|
||||
|
||||
# Wrapper function
|
||||
wrap_func_name = (func.class_name+"_" if class_info != None else "") + func.name.split("::")[-1] + "_wrapper"
|
||||
js_func_name = func.name
|
||||
if ns_name != None and ns_name != "cv":
|
||||
ns_parts = ns_name.split(".")
|
||||
if ns_parts[0] == "cv":
|
||||
ns_parts = ns_parts[1:]
|
||||
ns_part = "_".join(ns_parts) + "_"
|
||||
ns_id = '_'.join(ns_parts)
|
||||
ns_prefix = namespace_prefix_override.get(ns_id, ns_id)
|
||||
if ns_prefix:
|
||||
ns_prefix = ns_prefix + '_'
|
||||
else:
|
||||
ns_prefix = ''
|
||||
if class_info == None:
|
||||
js_func_name = ns_prefix + func.name
|
||||
wrap_func_name = js_func_name + "_wrapper"
|
||||
else:
|
||||
wrap_func_name = ns_prefix + func.class_name + "_" + func.name + "_wrapper"
|
||||
js_func_name = func.name
|
||||
|
||||
# TODO: Name functions based wrap directives or based on arguments list
|
||||
if index > 0:
|
||||
@@ -740,12 +762,22 @@ class JSWrapperGenerator(object):
|
||||
# step 2: generate bindings
|
||||
# Global functions
|
||||
for ns_name, ns in sorted(self.namespaces.items()):
|
||||
if ns_name.split('.')[0] != 'cv':
|
||||
ns_parts = ns_name.split('.')
|
||||
if ns_parts[0] != 'cv':
|
||||
print('Ignore namespace: {}'.format(ns_name))
|
||||
continue
|
||||
for name, func in sorted(ns.funcs.items()):
|
||||
else:
|
||||
ns_parts = ns_parts[1:]
|
||||
ns_id = '_'.join(ns_parts)
|
||||
ns_prefix = namespace_prefix_override.get(ns_id, ns_id)
|
||||
for name_id, func in sorted(ns.funcs.items()):
|
||||
name = func.name
|
||||
if ns_prefix:
|
||||
name = ns_prefix + '_' + name
|
||||
if name in ignore_list:
|
||||
continue
|
||||
if not name in white_list['']:
|
||||
#print('Not in whitelist: "{}" from ns={}'.format(name, ns_name))
|
||||
continue
|
||||
|
||||
ext_cnst = False
|
||||
@@ -769,7 +801,7 @@ class JSWrapperGenerator(object):
|
||||
continue
|
||||
|
||||
if with_wrapped_functions:
|
||||
binding, wrapper = self.gen_function_binding_with_wrapper(func, class_info=None)
|
||||
binding, wrapper = self.gen_function_binding_with_wrapper(func, ns_name, class_info=None)
|
||||
self.bindings += binding
|
||||
self.wrapper_funcs += wrapper
|
||||
else:
|
||||
@@ -802,7 +834,7 @@ class JSWrapperGenerator(object):
|
||||
class_bindings.append(constructor_template.substitute(signature=', '.join(args)))
|
||||
else:
|
||||
if with_wrapped_functions and (len(method.variants) > 1 or len(method.variants[0].args)>0 or "String" in method.variants[0].rettype):
|
||||
binding, wrapper = self.gen_function_binding_with_wrapper(method, class_info=class_info)
|
||||
binding, wrapper = self.gen_function_binding_with_wrapper(method, None, class_info=class_info)
|
||||
self.wrapper_funcs = self.wrapper_funcs + wrapper
|
||||
class_bindings = class_bindings + binding
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user