2017-06-20 20:19:43 +08:00
|
|
|
set(the_description "High-level GUI")
|
2017-06-03 20:28:53 +08:00
|
|
|
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()
|
2012-02-03 19:26:49 +08:00
|
|
|
|
2010-05-12 01:44:00 +08:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# CMake file for highgui. See root CMakeLists.txt
|
|
|
|
# Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
|
|
|
|
# Jose Luis Blanco, 2008
|
|
|
|
# ----------------------------------------------------------------------------
|
2012-01-25 00:55:47 +08:00
|
|
|
|
2015-12-31 21:31:26 +08:00
|
|
|
if(DEFINED WINRT AND NOT DEFINED ENABLE_WINRT_MODE_NATIVE)
|
Update cap_msmf.cpp
Add support for WinRT in the MF capture framework by removing the disallowed calls to enumerate devices and create a sample grabber sink and adding framework for the MediaCapture interface and a custom sink which interfaces with the sample grabber callback interface. The change requires discussion for making it completely functional as redundancy is required given that if the source is a video file, the old code pathways must be used. Otherwise all IMFMediaSession, IMFMediaSource, and IMFActivate code must use a MediaCapture code path and all sink code must use the CMediaSink custom sink.
Support for the custom sink is extended to non-WinRT not for compatibility as Windows Vista client is a minimum regardless, but because it offers more flexibility, could be faster and is able to be used as an optionally different code path during sink creation based on a future configuration parameter.
My discussion and proposal to finish this change:
Devices are so easily enumerated through WinRT Windows.Devices namespace that wrapping the calls in a library is quite a chore for little benefit though to get the various modes and formats could still be a worthwhile project. For now conditional compilation to remove videodevices and any offending non-video file related activity in videodevice. In my opinion, this is a different , far less fundamental and important change which can possibly be done as a future project and also much more easily implemented in C++/CX.
ImageGrabber has the IMFSampleGrabberSinkCallback replaced with a base class (SharedSampleGrabber) which also be is base class for ImageGrabberRT. This change is necessary as the custom sink does not require a thread to pump events which is done through MediaCapture already. IMFSampleGrabberSinkCallback is the common element between both models and that piece can be shared. Initializing the new ImageGrabberRT is as simple as passing an already initialized MediaCapture object and any video format/encoding parameters.
The concurrency event is necessary to wait for completion and is the way the underlying, IAsyncAction wrappers in the task library work as well. Native WIN32 event objects would be an option if HAVE_CONCURRENCY is not defined. I could even imagine doing it with sleep/thread yield and InterlockedCompareExchange yet I am not enthusiastic about that approach either. Since there is a specific compiler HAVE_ for concurrency, I do not like pulling it in though I think for WinRT it is safe to say we will always have it available though should probably conditionally compile with the Interlocked option as WIN32 events would require HAVE_WIN32.
It looks like C++/CX cannot be used for the IMediaExtension sink (which should not be a problem) as using COM objects requires WRL and though deriving from IMediaExtension can be done, there is little purpose without COM. Objects from C++/CX can be swapped to interact with objects from native C++ as Inspectable* can reinterpret_cast to the ref object IInspectable^ and vice-versa. A solution to the COM class with C++/CX would be great so we could have dual support. Also without #define for every WRL object in use, the code will get quite muddy given that the */^ would need to be ifdef'd everywhere.
Update cap_msmf.cpp
Fixed bugs and completed the change. I believe the new classes need to be moved to a header file as the file has become to large and more classes need to be added for handling all the asynchronous problems (one wrapping IAsyncAction in a task and another for making a task out of IAsyncAction). Unfortunately, blocking on the UI thread is not an option in WinRT so a synchronous architecture is considered "illegal" by Microsoft's standards even if implementable (C++/CX ppltasks library throws errors if you try it). Worse, either by design or a bug in the MF MediaCapture class with Custom Sinks causes a crash if stop/start previewing without reinitializing (spPreferredPreviewMediaType is fatally nulled). After decompiling Windows.Media.dll, I worked around this in my own projects by using an activate-able custom sink ID which strangely assigns 1 to this pointer allowing it to be reinitialized in what can only be described as a hack by Microsoft. This would add additional overhead to the project to implement especially for static libraries as it requires IDL/DLL exporting followed by manifest declaration. Better to document that it is not supported.
Furthermore, an additional class for IMFAttributes should be implemented to make clean architecture for passing around attributes as opposed to directly calling non-COM interface calls on the objects and making use of SetProperties which would also be a set up for an object that uses the RuntimeClass activation ID.
The remaining changes are not difficult and will be complete soon along with debug tracing messages.
Update cap_msmf.cpp
Create cap_msmf.h
Update cap_msmf.cpp
Update cap_msmf.h
Update cap_msmf.cpp
Update cap_msmf.h
Update and rename cap_msmf.h to cap_msmf.hpp
Update cap_msmf.cpp
Update CMakeLists.txt
Update cap_msmf.hpp
Update cap_msmf.cpp
Update cap_msmf.cpp
Update cap_msmf.cpp
Update cap_msmf.hpp
Update cap_msmf.hpp
Update cap_msmf.cpp
Successful test - samples are grabbed
Update cap_msmf.cpp
Update cap_msmf.hpp
Update cap_msmf.cpp
Update cap_msmf.hpp
Update cap_msmf.hpp
Update cap_msmf.cpp
Update cap_msmf.hpp
Update cap_msmf.cpp
Update cap_msmf.hpp
Update cap_msmf.cpp
Update cap_msmf.hpp
Create ppltasks_winrt.h
Update cap_msmf.hpp
Update cap_msmf.hpp
Update cap_msmf.cpp
Update ppltasks_winrt.h
Library updated and cleaned up with comments, marshaling, exceptions and linker settings
Update ppltasks_winrt.h
Fixed trailing whitespace
2013-12-14 16:53:30 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
|
|
|
endif()
|
|
|
|
|
2014-07-04 22:48:15 +08:00
|
|
|
if(APPLE)
|
2013-08-22 22:04:50 +08:00
|
|
|
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
|
2014-07-04 22:48:15 +08:00
|
|
|
list(APPEND HIGHGUI_LIBRARIES ${ZLIB_LIBRARIES})
|
2010-05-12 01:44:00 +08:00
|
|
|
endif()
|
|
|
|
|
2018-02-02 19:19:29 +08:00
|
|
|
if(HAVE_WEBP)
|
|
|
|
add_definitions(-DHAVE_WEBP)
|
|
|
|
endif()
|
|
|
|
|
2012-05-21 02:49:57 +08:00
|
|
|
set(highgui_hdrs
|
2014-08-01 22:11:20 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp
|
2012-05-21 02:49:57 +08:00
|
|
|
)
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2010-05-12 01:44:00 +08:00
|
|
|
set(highgui_srcs
|
2014-08-01 22:11:20 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/window.cpp
|
2017-04-19 19:08:37 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/roiSelector.cpp
|
2010-05-12 01:44:00 +08:00
|
|
|
)
|
2012-03-13 01:07:54 +08:00
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
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")
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2015-06-27 04:41:25 +08:00
|
|
|
# Removing WinRT API headers by default
|
|
|
|
list(REMOVE_ITEM highgui_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/highgui_winrt.hpp")
|
|
|
|
|
2013-04-18 02:02:01 +08:00
|
|
|
if(HAVE_QT5)
|
2017-10-10 03:12:52 +08:00
|
|
|
# "Automoc" doesn't work properly with opencv_world build, use QT5_WRAP_CPP() directly
|
|
|
|
#set(CMAKE_AUTOMOC ON)
|
|
|
|
|
2013-04-18 02:02:01 +08:00
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
QT5_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc)
|
2017-10-07 05:03:39 +08:00
|
|
|
QT5_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h)
|
2014-08-01 22:11:20 +08:00
|
|
|
list(APPEND highgui_srcs
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h
|
2017-10-07 05:03:39 +08:00
|
|
|
${_MOC_OUTFILES}
|
2014-08-01 22:11:20 +08:00
|
|
|
${_RCC_OUTFILES})
|
2013-04-18 02:02:01 +08:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
if(HAVE_QT_OPENGL)
|
|
|
|
add_definitions(${Qt5OpenGL_DEFINITIONS})
|
|
|
|
include_directories(${Qt5OpenGL_INCLUDE_DIRS})
|
|
|
|
list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
elseif(HAVE_QT)
|
2012-04-14 05:50:59 +08:00
|
|
|
if (HAVE_QT_OPENGL)
|
|
|
|
set(QT_USE_QTOPENGL TRUE)
|
|
|
|
endif()
|
2012-05-21 02:49:57 +08:00
|
|
|
include(${QT_USE_FILE})
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
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)
|
2012-04-14 05:50:59 +08:00
|
|
|
|
2013-06-06 18:09:33 +08:00
|
|
|
list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES})
|
2014-08-01 22:11:20 +08:00
|
|
|
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES})
|
2016-09-07 23:02:36 +08:00
|
|
|
ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag "")
|
2012-06-27 05:05:15 +08:00
|
|
|
if(${_have_flag})
|
2012-06-13 19:49:27 +08:00
|
|
|
set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
|
2012-06-08 01:21:29 +08:00
|
|
|
endif()
|
2015-06-27 04:41:25 +08:00
|
|
|
elseif(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.
|
2015-07-11 00:18:07 +08:00
|
|
|
message(STATUS " ${name}: WinRT detected. Adding WinRT API header")
|
2015-06-27 04:41:25 +08:00
|
|
|
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()
|
2015-06-02 23:33:21 +08:00
|
|
|
|
|
|
|
# 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)
|
2015-07-11 00:18:07 +08:00
|
|
|
message(STATUS " ${name}: Windows Phone detected")
|
2015-06-02 23:33:21 +08:00
|
|
|
elseif(OpenCV_ARCH STREQUAL "ARM")
|
2015-07-11 00:18:07 +08:00
|
|
|
message(STATUS " ${name}: ARM detected")
|
2015-06-27 04:41:25 +08:00
|
|
|
if(WINRT_STORE)
|
|
|
|
list(REMOVE_ITEM HIGHGUI_LIBRARIES "ws2_32")
|
2015-07-11 00:18:07 +08:00
|
|
|
message(STATUS " ${name}: Removing 'ws2_32.lib'")
|
2015-06-27 04:41:25 +08:00
|
|
|
endif()
|
2015-06-02 23:33:21 +08:00
|
|
|
endif()
|
2015-07-11 00:18:07 +08:00
|
|
|
message(STATUS " ${name}: Removing 'comctl32.lib, gdi32.lib, ole32.lib, setupapi.lib'")
|
|
|
|
message(STATUS " ${name}: Leaving '${HIGHGUI_LIBRARIES}'")
|
2015-06-02 23:33:21 +08:00
|
|
|
endif()
|
2013-03-27 23:03:51 +08:00
|
|
|
elseif(HAVE_WIN32UI)
|
2014-08-01 22:11:20 +08:00
|
|
|
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_w32.cpp)
|
2013-10-03 04:16:40 +08:00
|
|
|
elseif(HAVE_GTK OR HAVE_GTK3)
|
2014-08-01 22:11:20 +08:00
|
|
|
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_gtk.cpp)
|
2013-07-10 22:20:34 +08:00
|
|
|
elseif(HAVE_CARBON)
|
2014-08-01 22:11:20 +08:00
|
|
|
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_carbon.cpp)
|
2013-07-10 22:20:34 +08:00
|
|
|
list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime")
|
|
|
|
elseif(HAVE_COCOA)
|
2014-08-01 22:11:20 +08:00
|
|
|
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_cocoa.mm)
|
2013-07-10 22:20:34 +08:00
|
|
|
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
2010-07-12 23:29:31 +08:00
|
|
|
endif()
|
2012-05-25 04:10:13 +08:00
|
|
|
|
2012-05-21 16:53:38 +08:00
|
|
|
if(UNIX)
|
|
|
|
#these variables are set by CHECK_MODULE macro
|
|
|
|
foreach(P ${HIGHGUI_INCLUDE_DIRS})
|
|
|
|
ocv_include_directories(${P})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(P ${HIGHGUI_LIBRARY_DIRS})
|
|
|
|
link_directories(${P})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2010-05-12 01:44:00 +08:00
|
|
|
source_group("Src" FILES ${highgui_srcs} ${highgui_hdrs})
|
|
|
|
source_group("Include" FILES ${highgui_ext_hdrs})
|
2014-07-04 22:48:15 +08:00
|
|
|
ocv_set_module_sources(HEADERS ${highgui_ext_hdrs} SOURCES ${highgui_srcs} ${highgui_hdrs})
|
2012-02-03 19:26:49 +08:00
|
|
|
ocv_module_include_directories()
|
2011-04-27 00:10:26 +08:00
|
|
|
|
2014-07-04 22:48:15 +08:00
|
|
|
ocv_create_module(${HIGHGUI_LIBRARIES})
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
macro(ocv_highgui_configure_target)
|
2013-01-29 21:08:26 +08:00
|
|
|
if(APPLE)
|
2014-10-17 18:37:25 +08:00
|
|
|
add_apple_compiler_options(the_module)
|
2013-01-29 21:08:26 +08:00
|
|
|
endif()
|
|
|
|
|
2010-05-12 01:44:00 +08:00
|
|
|
if(MSVC)
|
2012-02-06 21:29:48 +08:00
|
|
|
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
|
2011-06-17 02:00:41 +08:00
|
|
|
endif()
|
|
|
|
|
2012-06-08 14:19:17 +08:00
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
|
2014-08-01 22:11:20 +08:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
if(NOT BUILD_opencv_world)
|
|
|
|
ocv_highgui_configure_target()
|
|
|
|
endif()
|
2012-03-19 19:21:01 +08:00
|
|
|
|
2012-02-17 04:29:35 +08:00
|
|
|
ocv_add_accuracy_tests()
|
2012-02-03 19:26:49 +08:00
|
|
|
ocv_add_perf_tests()
|