1# ---------------------------------------------------------------------------- 2# Detect 3rd-party video IO libraries 3# ---------------------------------------------------------------------------- 4 5ocv_clear_vars(HAVE_VFW) 6if(WITH_VFW) 7 try_compile(HAVE_VFW 8 "${OpenCV_BINARY_DIR}" 9 "${OpenCV_SOURCE_DIR}/cmake/checks/vfwtest.cpp" 10 CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=vfw32") 11endif(WITH_VFW) 12 13# --- GStreamer --- 14ocv_clear_vars(HAVE_GSTREAMER) 15# try to find gstreamer 1.x first 16if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10) 17 CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE) 18 CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO) 19 CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP) 20 CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF) 21 CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS) 22 23 if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS) 24 set(HAVE_GSTREAMER TRUE) 25 set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-1.0_VERSION}) 26 set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-1.0_VERSION}) 27 set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-1.0_VERSION}) 28 set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-1.0_VERSION}) 29 set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION}) 30 endif() 31 32endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10) 33 34# if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it 35if(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10) 36 CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER_BASE) 37 CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER_VIDEO) 38 CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER_APP) 39 CHECK_MODULE(gstreamer-riff-0.10 HAVE_GSTREAMER_RIFF) 40 CHECK_MODULE(gstreamer-pbutils-0.10 HAVE_GSTREAMER_PBUTILS) 41 42 if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS) 43 set(HAVE_GSTREAMER TRUE) 44 set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-0.10_VERSION}) 45 set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-0.10_VERSION}) 46 set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-0.10_VERSION}) 47 set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-0.10_VERSION}) 48 set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-0.10_VERSION}) 49 endif() 50endif(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10) 51 52# --- unicap --- 53ocv_clear_vars(HAVE_UNICAP) 54if(WITH_UNICAP) 55 CHECK_MODULE(libunicap HAVE_UNICAP_) 56 CHECK_MODULE(libucil HAVE_UNICAP_UCIL) 57 if(HAVE_UNICAP_ AND HAVE_UNICAP_UCIL) 58 set(HAVE_UNICAP TRUE) 59 endif() 60endif(WITH_UNICAP) 61 62# --- PvApi --- 63ocv_clear_vars(HAVE_PVAPI) 64if(WITH_PVAPI) 65 find_path(PVAPI_INCLUDE_PATH "PvApi.h" 66 PATHS /usr/local /opt /usr ENV ProgramFiles ENV ProgramW6432 67 PATH_SUFFIXES include "Allied Vision Technologies/GigESDK/inc-pc" "AVT GigE SDK/inc-pc" "GigESDK/inc-pc" 68 DOC "The path to PvAPI header") 69 70 if(PVAPI_INCLUDE_PATH) 71 if(X86 AND NOT WIN32) 72 set(PVAPI_SDK_SUBDIR x86) 73 elseif(X86_64) 74 set(PVAPI_SDK_SUBDIR x64) 75 elseif(ARM) 76 set(PVAPI_SDK_SUBDIR arm) 77 endif() 78 79 get_filename_component(_PVAPI_LIBRARY "${PVAPI_INCLUDE_PATH}/../lib-pc" ABSOLUTE) 80 if(PVAPI_SDK_SUBDIR) 81 set(_PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${PVAPI_SDK_SUBDIR}") 82 endif() 83 if(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX) 84 set(_PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_OPENCV_GCC_VERSION_MAJOR}.${CMAKE_OPENCV_GCC_VERSION_MINOR}") 85 endif() 86 87 if(WIN32) 88 if(MINGW) 89 set(PVAPI_DEFINITIONS "-DPVDECL=__stdcall") 90 endif(MINGW) 91 set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/PvAPI.lib" CACHE PATH "The PvAPI library") 92 else(WIN32) 93 set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_STATIC_LIBRARY_PREFIX}PvAPI${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE PATH "The PvAPI library") 94 endif(WIN32) 95 if(EXISTS "${PVAPI_LIBRARY}") 96 set(HAVE_PVAPI TRUE) 97 endif() 98 endif(PVAPI_INCLUDE_PATH) 99endif(WITH_PVAPI) 100 101# --- GigEVisionSDK --- 102ocv_clear_vars(HAVE_GIGE_API) 103if(WITH_GIGEAPI) 104 find_path(GIGEAPI_INCLUDE_PATH "GigEVisionSDK.h" 105 PATHS /usr/local /var /opt /usr ENV ProgramFiles ENV ProgramW6432 106 PATH_SUFFIXES include "Smartek Vision Technologies/GigEVisionSDK/gige_cpp" "GigEVisionSDK/gige_cpp" "GigEVisionSDK/gige_c" 107 DOC "The path to Smartek GigEVisionSDK header") 108 FIND_LIBRARY(GIGEAPI_LIBRARIES NAMES GigEVisionSDK) 109 if(GIGEAPI_LIBRARIES AND GIGEAPI_INCLUDE_PATH) 110 set(HAVE_GIGE_API TRUE) 111 endif() 112endif(WITH_GIGEAPI) 113 114# --- Dc1394 --- 115ocv_clear_vars(HAVE_DC1394 HAVE_DC1394_2) 116if(WITH_1394) 117 if(WIN32 AND MINGW) 118 find_path(CMU1394_INCLUDE_PATH "/1394common.h" 119 PATH_SUFFIXES include 120 DOC "The path to cmu1394 headers") 121 find_path(DC1394_2_INCLUDE_PATH "/dc1394/dc1394.h" 122 PATH_SUFFIXES include 123 DOC "The path to DC1394 2.x headers") 124 if(CMU1394_INCLUDE_PATH AND DC1394_2_INCLUDE_PATH) 125 set(CMU1394_LIB_DIR "${CMU1394_INCLUDE_PATH}/../lib" CACHE PATH "Full path of CMU1394 library directory") 126 set(DC1394_2_LIB_DIR "${DC1394_2_INCLUDE_PATH}/../lib" CACHE PATH "Full path of DC1394 2.x library directory") 127 if(EXISTS "${CMU1394_LIB_DIR}/lib1394camera.a" AND EXISTS "${DC1394_2_LIB_DIR}/libdc1394.a") 128 set(HAVE_DC1394_2 TRUE) 129 endif() 130 endif() 131 if(HAVE_DC1394_2) 132 ocv_parse_pkg("libdc1394-2" "${DC1394_2_LIB_DIR}/pkgconfig" "") 133 ocv_include_directories(${DC1394_2_INCLUDE_PATH}) 134 set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES} 135 "${DC1394_2_LIB_DIR}/libdc1394.a" 136 "${CMU1394_LIB_DIR}/lib1394camera.a") 137 endif(HAVE_DC1394_2) 138 else(WIN32 AND MINGW) 139 CHECK_MODULE(libdc1394-2 HAVE_DC1394_2) 140 if(NOT HAVE_DC1394_2) 141 CHECK_MODULE(libdc1394 HAVE_DC1394) 142 endif() 143 endif(WIN32 AND MINGW) 144endif(WITH_1394) 145 146# --- xine --- 147ocv_clear_vars(HAVE_XINE) 148if(WITH_XINE) 149 CHECK_MODULE(libxine HAVE_XINE) 150endif(WITH_XINE) 151 152# --- V4L --- 153ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO) 154if(WITH_V4L) 155 if(WITH_LIBV4L) 156 CHECK_MODULE(libv4l1 HAVE_LIBV4L1) 157 CHECK_MODULE(libv4l2 HAVE_LIBV4L2) 158 if(HAVE_LIBV4L1 AND HAVE_LIBV4L2) 159 set(HAVE_LIBV4L YES) 160 else() 161 set(HAVE_LIBV4L NO) 162 endif() 163 endif() 164 CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L) 165 CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2) 166 CHECK_INCLUDE_FILE(sys/videoio.h HAVE_VIDEOIO) 167endif(WITH_V4L) 168 169# --- OpenNI --- 170ocv_clear_vars(HAVE_OPENNI HAVE_OPENNI_PRIME_SENSOR_MODULE) 171if(WITH_OPENNI) 172 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenNI.cmake") 173endif(WITH_OPENNI) 174 175ocv_clear_vars(HAVE_OPENNI2) 176if(WITH_OPENNI2) 177 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenNI2.cmake") 178endif(WITH_OPENNI2) 179 180# --- XIMEA --- 181ocv_clear_vars(HAVE_XIMEA) 182if(WITH_XIMEA) 183 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindXimea.cmake") 184 if(XIMEA_FOUND) 185 set(HAVE_XIMEA TRUE) 186 endif() 187endif(WITH_XIMEA) 188 189# --- FFMPEG --- 190ocv_clear_vars(HAVE_FFMPEG HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_FFMPEG_RESAMPLE HAVE_GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG) 191if(WITH_FFMPEG) 192 if(WIN32 AND NOT ARM) 193 include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg_version.cmake") 194 elseif(UNIX) 195 CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC) 196 CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT) 197 CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL) 198 CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE) 199 CHECK_MODULE(libavresample HAVE_FFMPEG_RESAMPLE) 200 201 CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG) 202 CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG) 203 if(NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG) 204 if(EXISTS /usr/include/ffmpeg/libavformat/avformat.h OR HAVE_FFMPEG_SWSCALE) 205 set(HAVE_GENTOO_FFMPEG TRUE) 206 endif() 207 endif() 208 if(HAVE_FFMPEG_CODEC AND HAVE_FFMPEG_FORMAT AND HAVE_FFMPEG_UTIL AND HAVE_FFMPEG_SWSCALE) 209 set(HAVE_FFMPEG TRUE) 210 endif() 211 212 if(HAVE_FFMPEG) 213 # Find the bzip2 library because it is required on some systems 214 FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2) 215 if(NOT BZIP2_LIBRARIES) 216 # Do an other trial 217 FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib) 218 endif() 219 else() 220 find_path(FFMPEG_INCLUDE_DIR "libavformat/avformat.h" 221 PATHS /usr/local /usr /opt 222 PATH_SUFFIXES include 223 DOC "The path to FFMPEG headers") 224 if(FFMPEG_INCLUDE_DIR) 225 set(HAVE_GENTOO_FFMPEG TRUE) 226 set(FFMPEG_LIB_DIR "${FFMPEG_INCLUDE_DIR}/../lib" CACHE PATH "Full path of FFMPEG library directory") 227 find_library(FFMPEG_CODEC_LIB "avcodec" HINTS "${FFMPEG_LIB_DIR}") 228 find_library(FFMPEG_FORMAT_LIB "avformat" HINTS "${FFMPEG_LIB_DIR}") 229 find_library(FFMPEG_UTIL_LIB "avutil" HINTS "${FFMPEG_LIB_DIR}") 230 find_library(FFMPEG_SWSCALE_LIB "swscale" HINTS "${FFMPEG_LIB_DIR}") 231 find_library(FFMPEG_RESAMPLE_LIB "avresample" HINTS "${FFMPEG_LIB_DIR}") 232 if(FFMPEG_CODEC_LIB) 233 set(HAVE_FFMPEG_CODEC 1) 234 endif() 235 if(FFMPEG_FORMAT_LIB) 236 set(HAVE_FFMPEG_FORMAT 1) 237 endif() 238 if(FFMPEG_UTIL_LIB) 239 set(HAVE_FFMPEG_UTIL 1) 240 endif() 241 if(FFMPEG_SWSCALE_LIB) 242 set(HAVE_FFMPEG_SWSCALE 1) 243 endif() 244 if(FFMPEG_CODEC_LIB AND FFMPEG_FORMAT_LIB AND 245 FFMPEG_UTIL_LIB AND FFMPEG_SWSCALE_LIB) 246 set(ALIASOF_libavcodec_VERSION "Unknown") 247 set(ALIASOF_libavformat_VERSION "Unknown") 248 set(ALIASOF_libavutil_VERSION "Unknown") 249 set(ALIASOF_libswscale_VERSION "Unknown") 250 set(HAVE_FFMPEG 1) 251 if(FFMPEG_RESAMPLE_LIB) 252 set(HAVE_FFMPEG_RESAMPLE 1) 253 set(ALIASOF_libavresample_VERSION "Unknown") 254 endif() 255 endif() 256 endif(FFMPEG_INCLUDE_DIR) 257 if(HAVE_FFMPEG) 258 set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES} "${FFMPEG_LIB_DIR}/libavcodec.a" 259 "${FFMPEG_LIB_DIR}/libavformat.a" "${FFMPEG_LIB_DIR}/libavutil.a" 260 "${FFMPEG_LIB_DIR}/libswscale.a") 261 if(HAVE_FFMPEG_RESAMPLE) 262 set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES} "${FFMPEG_LIB_DIR}/libavresample.a") 263 endif() 264 ocv_include_directories(${FFMPEG_INCLUDE_DIR}) 265 endif(HAVE_FFMPEG) 266 endif() 267 endif() 268endif(WITH_FFMPEG) 269 270# --- VideoInput/DirectShow --- 271if(WITH_DSHOW) 272 # always have VideoInput on Windows 273 set(HAVE_DSHOW 1) 274endif(WITH_DSHOW) 275 276# --- VideoInput/Microsoft Media Foundation --- 277ocv_clear_vars(HAVE_MSMF) 278if(WITH_MSMF) 279 check_include_file(Mfapi.h HAVE_MSMF) 280endif(WITH_MSMF) 281 282# --- Extra HighGUI and VideoIO libs on Windows --- 283if(WIN32) 284 list(APPEND HIGHGUI_LIBRARIES comctl32 gdi32 ole32 setupapi ws2_32) 285 if(HAVE_VFW) 286 list(APPEND VIDEOIO_LIBRARIES vfw32) 287 endif() 288 if(MINGW64) 289 list(APPEND VIDEOIO_LIBRARIES avifil32 avicap32 winmm msvfw32) 290 list(REMOVE_ITEM VIDEOIO_LIBRARIES vfw32) 291 elseif(MINGW) 292 list(APPEND VIDEOIO_LIBRARIES winmm) 293 endif() 294endif(WIN32) 295 296# --- Apple AV Foundation --- 297if(WITH_AVFOUNDATION) 298 set(HAVE_AVFOUNDATION YES) 299endif() 300 301# --- QuickTime --- 302if (NOT IOS) 303 if(WITH_QUICKTIME) 304 set(HAVE_QUICKTIME YES) 305 elseif(APPLE AND CMAKE_COMPILER_IS_CLANGCXX) 306 set(HAVE_QTKIT YES) 307 endif() 308endif() 309 310# --- Intel Perceptual Computing SDK --- 311if(WITH_INTELPERC) 312 include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIntelPerCSDK.cmake") 313endif(WITH_INTELPERC) 314 315# --- gPhoto2 --- 316ocv_clear_vars(HAVE_GPHOTO2) 317if(WITH_GPHOTO2) 318 CHECK_MODULE(libgphoto2 HAVE_GPHOTO2) 319endif(WITH_GPHOTO2) 320