1 # ----------------------------------------------------------------------------
2 # Detect 3rd-party video IO libraries
3 # ----------------------------------------------------------------------------
5 ocv_clear_vars(HAVE_VFW)
9 "${OpenCV_SOURCE_DIR}/cmake/checks/vfwtest.cpp"
10 CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=vfw32")
14 ocv_clear_vars(HAVE_GSTREAMER)
15 # try to find gstreamer 1.x first if 0.10 was not requested
16 if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
18 SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}")
19 FIND_PACKAGE(GstreamerWindows)
20 IF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY)
21 set(HAVE_GSTREAMER TRUE)
22 set(GSTREAMER_BASE_VERSION 1.0)
23 set(GSTREAMER_VIDEO_VERSION 1.0)
24 set(GSTREAMER_APP_VERSION 1.0)
25 set(GSTREAMER_RIFF_VERSION 1.0)
26 set(GSTREAMER_PBUTILS_VERSION 1.0)
27 ENDIF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY)
30 CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE VIDEOIO)
31 CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO VIDEOIO)
32 CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP VIDEOIO)
33 CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF VIDEOIO)
34 CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS VIDEOIO)
36 if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
37 set(HAVE_GSTREAMER TRUE)
38 set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-1.0_VERSION})
39 set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-1.0_VERSION})
40 set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-1.0_VERSION})
41 set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-1.0_VERSION})
42 set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION})
45 endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
47 # if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it
48 if(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10)
49 CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER_BASE VIDEOIO)
50 CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER_VIDEO VIDEOIO)
51 CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER_APP VIDEOIO)
52 CHECK_MODULE(gstreamer-riff-0.10 HAVE_GSTREAMER_RIFF VIDEOIO)
53 CHECK_MODULE(gstreamer-pbutils-0.10 HAVE_GSTREAMER_PBUTILS VIDEOIO)
55 if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
56 set(HAVE_GSTREAMER TRUE)
57 set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-0.10_VERSION})
58 set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-0.10_VERSION})
59 set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-0.10_VERSION})
60 set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-0.10_VERSION})
61 set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-0.10_VERSION})
63 endif(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10)
66 ocv_clear_vars(HAVE_UNICAP)
68 CHECK_MODULE(libunicap HAVE_UNICAP_ VIDEOIO)
69 CHECK_MODULE(libucil HAVE_UNICAP_UCIL VIDEOIO)
70 if(HAVE_UNICAP_ AND HAVE_UNICAP_UCIL)
76 ocv_clear_vars(HAVE_PVAPI)
78 find_path(PVAPI_INCLUDE_PATH "PvApi.h"
79 PATHS /usr/local /opt /usr ENV ProgramFiles ENV ProgramW6432
80 PATH_SUFFIXES include "Allied Vision Technologies/GigESDK/inc-pc" "AVT GigE SDK/inc-pc" "GigESDK/inc-pc"
81 DOC "The path to PvAPI header")
83 if(PVAPI_INCLUDE_PATH)
85 set(PVAPI_SDK_SUBDIR x86)
87 set(PVAPI_SDK_SUBDIR x64)
89 set(PVAPI_SDK_SUBDIR arm)
92 get_filename_component(_PVAPI_LIBRARY_HINT "${PVAPI_INCLUDE_PATH}/../lib-pc" ABSOLUTE)
94 find_library(PVAPI_LIBRARY NAMES "PvAPI" PATHS "${_PVAPI_LIBRARY_HINT}")
99 set(PVAPI_DEFINITIONS "-DPVDECL=__stdcall")
104 endif(PVAPI_INCLUDE_PATH)
107 # --- GigEVisionSDK ---
108 ocv_clear_vars(HAVE_GIGE_API)
110 find_path(GIGEAPI_INCLUDE_PATH "GigEVisionSDK.h"
111 PATHS /usr/local /var /opt /usr ENV ProgramFiles ENV ProgramW6432
112 PATH_SUFFIXES include "Smartek Vision Technologies/GigEVisionSDK/gige_cpp" "GigEVisionSDK/gige_cpp" "GigEVisionSDK/gige_c"
113 DOC "The path to Smartek GigEVisionSDK header")
114 FIND_LIBRARY(GIGEAPI_LIBRARIES NAMES GigEVisionSDK)
115 if(GIGEAPI_LIBRARIES AND GIGEAPI_INCLUDE_PATH)
116 set(HAVE_GIGE_API TRUE)
121 ocv_clear_vars(HAVE_ARAVIS_API)
123 check_module(glib-2.0 HAVE_ARAVIS_GLIB VIDEOIO)
125 find_path(ARAVIS_INCLUDE_PATH "arv.h"
126 PATHS /usr/local /var /opt /usr ENV ProgramFiles ENV ProgramW6432
127 PATH_SUFFIXES include "aravis-0.6" "aravis-0.4"
128 DOC "The path to Aravis SDK headers")
129 find_library(ARAVIS_LIBRARIES NAMES "aravis-0.6" "aravis-0.4" )
130 if(ARAVIS_LIBRARIES AND ARAVIS_INCLUDE_PATH)
131 set(HAVE_ARAVIS_API TRUE)
134 message("Can not build Aravis support without glib2")
139 ocv_clear_vars(HAVE_DC1394 HAVE_DC1394_2)
142 find_path(CMU1394_INCLUDE_PATH "/1394common.h"
143 PATH_SUFFIXES include
144 DOC "The path to cmu1394 headers")
145 find_path(DC1394_2_INCLUDE_PATH "/dc1394/dc1394.h"
146 PATH_SUFFIXES include
147 DOC "The path to DC1394 2.x headers")
148 if(CMU1394_INCLUDE_PATH AND DC1394_2_INCLUDE_PATH)
149 set(CMU1394_LIB_DIR "${CMU1394_INCLUDE_PATH}/../lib" CACHE PATH "Full path of CMU1394 library directory")
150 set(DC1394_2_LIB_DIR "${DC1394_2_INCLUDE_PATH}/../lib" CACHE PATH "Full path of DC1394 2.x library directory")
151 if(EXISTS "${CMU1394_LIB_DIR}/lib1394camera.a" AND EXISTS "${DC1394_2_LIB_DIR}/libdc1394.a")
152 set(HAVE_DC1394_2 TRUE)
156 ocv_parse_pkg("libdc1394-2" "${DC1394_2_LIB_DIR}/pkgconfig" "")
157 ocv_include_directories(${DC1394_2_INCLUDE_PATH})
158 set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES}
159 "${DC1394_2_LIB_DIR}/libdc1394.a"
160 "${CMU1394_LIB_DIR}/lib1394camera.a")
162 else(WIN32 AND MINGW)
163 CHECK_MODULE(libdc1394-2 HAVE_DC1394_2 VIDEOIO)
164 if(NOT HAVE_DC1394_2)
165 CHECK_MODULE(libdc1394 HAVE_DC1394 VIDEOIO)
167 endif(WIN32 AND MINGW)
171 ocv_clear_vars(HAVE_XINE)
173 CHECK_MODULE(libxine HAVE_XINE VIDEOIO)
177 ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO)
180 CHECK_MODULE(libv4l1 HAVE_LIBV4L1 VIDEOIO)
181 CHECK_MODULE(libv4l2 HAVE_LIBV4L2 VIDEOIO)
182 if(HAVE_LIBV4L1 AND HAVE_LIBV4L2)
188 CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
189 CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
190 CHECK_INCLUDE_FILE(sys/videoio.h HAVE_VIDEOIO)
194 ocv_clear_vars(HAVE_OPENNI HAVE_OPENNI_PRIME_SENSOR_MODULE)
196 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenNI.cmake")
199 ocv_clear_vars(HAVE_OPENNI2)
201 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenNI2.cmake")
205 ocv_clear_vars(HAVE_XIMEA)
207 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindXimea.cmake")
214 ocv_clear_vars(HAVE_FFMPEG)
215 if(WITH_FFMPEG) # try FFmpeg autodetection
216 if(OPENCV_FFMPEG_USE_FIND_PACKAGE)
217 if(OPENCV_FFMPEG_USE_FIND_PACKAGE STREQUAL "1" OR OPENCV_FFMPEG_USE_FIND_PACKAGE STREQUAL "ON")
218 set(OPENCV_FFMPEG_USE_FIND_PACKAGE "FFMPEG")
220 find_package(${OPENCV_FFMPEG_USE_FIND_PACKAGE}) # Required components: AVCODEC AVFORMAT AVUTIL SWSCALE
221 if(FFMPEG_FOUND OR FFmpeg_FOUND)
222 set(HAVE_FFMPEG TRUE)
224 message(STATUS "Can't find FFmpeg via find_package(${OPENCV_FFMPEG_USE_FIND_PACKAGE})")
226 elseif(WIN32 AND NOT ARM AND NOT OPENCV_FFMPEG_SKIP_DOWNLOAD)
227 include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg.cmake")
228 download_win_ffmpeg(FFMPEG_CMAKE_SCRIPT)
229 if(FFMPEG_CMAKE_SCRIPT)
230 set(HAVE_FFMPEG TRUE)
231 set(HAVE_FFMPEG_WRAPPER 1)
232 include("${FFMPEG_CMAKE_SCRIPT}")
234 elseif(PKG_CONFIG_FOUND)
235 ocv_check_modules(FFMPEG libavcodec libavformat libavutil libswscale)
236 ocv_check_modules(FFMPEG_libavresample libavresample)
237 if(FFMPEG_libavresample_FOUND)
238 ocv_append_build_options(FFMPEG FFMPEG_libavresample)
241 message(STATUS "Can't find ffmpeg - 'pkg-config' utility is missing")
245 AND NOT HAVE_FFMPEG_WRAPPER
247 try_compile(__VALID_FFMPEG
248 "${OpenCV_BINARY_DIR}"
249 "${OpenCV_SOURCE_DIR}/cmake/checks/ffmpeg_test.cpp"
250 CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${FFMPEG_INCLUDE_DIRS}"
251 "-DLINK_DIRECTORIES:STRING=${FFMPEG_LIBRARY_DIRS}"
252 "-DLINK_LIBRARIES:STRING=${FFMPEG_LIBRARIES}"
253 OUTPUT_VARIABLE TRY_OUT
255 if(NOT __VALID_FFMPEG)
256 #message(FATAL_ERROR "FFMPEG: test check build log:\n${TRY_OUT}")
257 message(STATUS "WARNING: Can't build ffmpeg test code")
258 set(HAVE_FFMPEG FALSE)
260 ocv_append_build_options(VIDEOIO FFMPEG)
264 # --- VideoInput/DirectShow ---
266 if(MSVC_VERSION GREATER 1499)
268 elseif(NOT HAVE_DSHOW)
269 check_include_file(DShow.h HAVE_DSHOW)
273 # --- VideoInput/Microsoft Media Foundation ---
274 ocv_clear_vars(HAVE_MSMF)
276 check_include_file(Mfapi.h HAVE_MSMF)
277 check_include_file(D3D11.h D3D11_found)
278 check_include_file(D3d11_4.h D3D11_4_found)
279 if(D3D11_found AND D3D11_4_found)
286 # --- Extra HighGUI and VideoIO libs on Windows ---
288 list(APPEND HIGHGUI_LIBRARIES comctl32 gdi32 ole32 setupapi ws2_32)
290 list(APPEND VIDEOIO_LIBRARIES vfw32)
293 list(APPEND VIDEOIO_LIBRARIES avifil32 avicap32 winmm msvfw32)
294 list(REMOVE_ITEM VIDEOIO_LIBRARIES vfw32)
296 list(APPEND VIDEOIO_LIBRARIES winmm)
301 if(WITH_AVFOUNDATION)
302 set(HAVE_AVFOUNDATION YES)
306 set(HAVE_QUICKTIME YES)
313 # --- Intel Perceptual Computing SDK ---
315 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIntelPerCSDK.cmake")
316 endif(WITH_INTELPERC)
319 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectMediaSDK.cmake")
323 ocv_clear_vars(HAVE_GPHOTO2)
325 CHECK_MODULE(libgphoto2 HAVE_GPHOTO2 VIDEOIO)
328 # --- VA & VA_INTEL ---
330 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindVA_INTEL.cmake")
331 if(VA_INTEL_IOCL_INCLUDE_DIR)
332 ocv_include_directories(${VA_INTEL_IOCL_INCLUDE_DIR})
338 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindVA.cmake")
340 ocv_include_directories(${VA_INCLUDE_DIR})