opencv/modules/highgui/CMakeLists.txt

170 lines
5.8 KiB
CMake
Raw Normal View History

2017-06-20 20:19:43 +08:00
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()
# ----------------------------------------------------------------------------
# CMake file for highgui. See root CMakeLists.txt
# Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
# Jose Luis Blanco, 2008
# ----------------------------------------------------------------------------
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)
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
2014-07-04 22:48:15 +08:00
list(APPEND HIGHGUI_LIBRARIES ${ZLIB_LIBRARIES})
endif()
2018-02-02 19:19:29 +08:00
if(HAVE_WEBP)
add_definitions(-DHAVE_WEBP)
endif()
set(highgui_hdrs
2014-08-01 22:11:20 +08:00
${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp
)
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
)
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")
# Removing WinRT API headers by default
list(REMOVE_ITEM highgui_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/highgui_winrt.hpp")
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)
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)
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
${_MOC_OUTFILES}
2014-08-01 22:11:20 +08:00
${_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()
if(HAVE_QT_OPENGL)
add_definitions(${Qt5OpenGL_DEFINITIONS})
include_directories(${Qt5OpenGL_INCLUDE_DIRS})
list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES})
endif()
elseif(HAVE_QT)
if (HAVE_QT_OPENGL)
set(QT_USE_QTOPENGL TRUE)
endif()
include(${QT_USE_FILE})
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)
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})
set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
2012-06-08 01:21:29 +08:00
endif()
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.
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_WIN32UI)
2014-08-01 22:11:20 +08:00
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_GTK OR HAVE_GTK3)
2014-08-01 22:11:20 +08:00
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_gtk.cpp)
elseif(HAVE_CARBON)
2014-08-01 22:11:20 +08:00
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_carbon.cpp)
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)
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
endif()
2012-05-25 04:10:13 +08:00
if(TRUE)
# these variables are set by 'ocv_append_build_options(HIGHGUI ...)'
2012-05-21 16:53:38 +08:00
foreach(P ${HIGHGUI_INCLUDE_DIRS})
ocv_include_directories(${P})
endforeach()
foreach(P ${HIGHGUI_LIBRARY_DIRS})
link_directories(${P})
endforeach()
endif()
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})
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})
2014-08-01 22:11:20 +08:00
macro(ocv_highgui_configure_target)
if(APPLE)
add_apple_compiler_options(${the_module})
endif()
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()
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
ocv_add_accuracy_tests()
ocv_add_perf_tests()