From 09bc99a0c0450358c6beff77db2967ae7cca1b9b Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 27 Mar 2013 08:03:51 -0700 Subject: [PATCH] HAVE_WIN32UI and HAVE_VFW checks and defines added. --- CMakeLists.txt | 10 ++++++++-- cmake/OpenCVFindLibsGUI.cmake | 10 ++++++++++ cmake/OpenCVFindLibsVideo.cmake | 11 ++++++++++- cmake/checks/vfwtest.cpp | 10 ++++++++++ cmake/checks/win32uitest.cpp | 11 +++++++++++ cmake/templates/cvconfig.h.cmake | 6 ++++++ modules/core/include/opencv2/core/types_c.h | 1 - modules/highgui/CMakeLists.txt | 2 +- modules/highgui/perf/perf_precomp.hpp | 6 ++---- modules/highgui/src/cap.cpp | 1 - modules/highgui/src/cap_ffmpeg.cpp | 4 ++-- modules/highgui/src/precomp.hpp | 8 -------- modules/highgui/src/window.cpp | 12 ++++++------ modules/highgui/test/test_ffmpeg.cpp | 2 +- modules/highgui/test/test_gui.cpp | 2 +- modules/highgui/test/test_precomp.hpp | 7 ++----- 16 files changed, 70 insertions(+), 33 deletions(-) create mode 100644 cmake/checks/vfwtest.cpp create mode 100644 cmake/checks/win32uitest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b7f8c2..3a50ac3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS AND NOT APPLE) ) OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON) +OCV_OPTION(WITH_VFW "Include Video for Windows support" ON IF (WIN32)) OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS)) OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) ) OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) ) @@ -132,6 +133,7 @@ OCV_OPTION(WITH_PNG "Include PNG support" ON OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" ON IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) ) +OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON IF (WIN32) ) OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE ) OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) ) OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF WIN32 ) @@ -607,8 +609,8 @@ else() if(DEFINED WITH_QT) status(" QT 4.x:" NO) endif() - if(WIN32) - status(" Win32 UI:" ARM THEN NO ELSE YES) + if(DEFINED WITH_WIN32UI) + status(" Win32 UI:" HAVE_WIN32UI THEN YES ELSE NO) else() if(APPLE) if(WITH_CARBON) @@ -665,6 +667,10 @@ endif() status("") status(" Video I/O:") +if (DEFINED WITH_VFW) + status(" Video for Windows:" HAVE_VFW THEN YES ELSE NO) +endif(DEFINED WITH_VFW) + if(DEFINED WITH_1394) status(" DC1394 1.x:" HAVE_DC1394 THEN "YES (ver ${ALIASOF_libdc1394_VERSION})" ELSE NO) status(" DC1394 2.x:" HAVE_DC1394_2 THEN "YES (ver ${ALIASOF_libdc1394-2_VERSION})" ELSE NO) diff --git a/cmake/OpenCVFindLibsGUI.cmake b/cmake/OpenCVFindLibsGUI.cmake index c883a80..1409544 100644 --- a/cmake/OpenCVFindLibsGUI.cmake +++ b/cmake/OpenCVFindLibsGUI.cmake @@ -2,6 +2,16 @@ # Detect 3rd-party GUI libraries # ---------------------------------------------------------------------------- +#--- Win32 UI --- +ocv_clear_vars(HAVE_WIN32UI) +if(WITH_WIN32UI) + TRY_COMPILE(HAVE_WIN32UI + "${OPENCV_BINARY_DIR}/CMakeFiles/CMakeTmp" + "${OpenCV_SOURCE_DIR}/cmake/checks/win32uitest.cpp" + CMAKE_FLAGS "\"user32.lib\" \"gdi32.lib\"" + OUTPUT_VARIABLE OUTPUT) +endif(WITH_WIN32UI) + # --- QT4 --- ocv_clear_vars(HAVE_QT) if(WITH_QT) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 3556ba5..9cb7f7c 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -2,6 +2,15 @@ # Detect 3rd-party video IO libraries # ---------------------------------------------------------------------------- +ocv_clear_vars(HAVE_VFW) +if (WITH_VFW) + TRY_COMPILE(HAVE_VFW + "${OPENCV_BINARY_DIR}/CMakeFiles/CMakeTmp" + "${OpenCV_SOURCE_DIR}/cmake/checks/vfwtest.cpp" + CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=vfw32" + OUTPUT_VARIABLE OUTPUT) + endif(WITH_VFW) + # --- GStreamer --- ocv_clear_vars(HAVE_GSTREAMER) if(WITH_GSTREAMER) @@ -37,7 +46,7 @@ if(WITH_PVAPI) set(PVAPI_SDK_SUBDIR x86) elseif(X86_64) set(PVAPI_SDK_SUBDIR x64) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES arm) + elseif(ARM) set(PVAPI_SDK_SUBDIR arm) endif() diff --git a/cmake/checks/vfwtest.cpp b/cmake/checks/vfwtest.cpp new file mode 100644 index 0000000..63d5457 --- /dev/null +++ b/cmake/checks/vfwtest.cpp @@ -0,0 +1,10 @@ + +#include +#include + +int main() +{ + AVIFileInit(); + AVIFileExit(); + return 0; +} \ No newline at end of file diff --git a/cmake/checks/win32uitest.cpp b/cmake/checks/win32uitest.cpp new file mode 100644 index 0000000..6f13a09 --- /dev/null +++ b/cmake/checks/win32uitest.cpp @@ -0,0 +1,11 @@ +#include + +int main(int argc, char** argv) +{ + CreateWindow(NULL /*lpClassName*/, NULL /*lpWindowName*/, 0 /*dwStyle*/, 0 /*x*/, + 0 /*y*/, 0 /*nWidth*/, 0 /*nHeight*/, NULL /*hWndParent*/, NULL /*hMenu*/, + NULL /*hInstance*/, NULL /*lpParam*/); + DeleteDC(NULL); + + return 0; +} diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index 8552207..ff6b5c8 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -13,6 +13,9 @@ */ #cmakedefine HAVE_ALLOCA_H 1 +/* Video for Windows support */ +#cmakedefine HAVE_VFW + /* V4L capturing support */ #cmakedefine HAVE_CAMV4L @@ -55,6 +58,9 @@ /* GTK+ 2.0 Thread support */ #cmakedefine HAVE_GTHREAD +/* Win32 UI */ +#cmakedefine HAVE_WIN32UI + /* GTK+ 2.x toolkit */ #cmakedefine HAVE_GTK diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index be959a5..3a08304 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -322,7 +322,6 @@ CV_INLINE int cvRound( double value ) return (int)lrint(value); # endif #else - // while this is not IEEE754-compliant rounding, it's usually a good enough approximation double intpart, fractpart; fractpart = modf(value, &intpart); if ((abs(fractpart) != 0.5) || ((((int)intpart) % 2) != 0)) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 59ec616..2888c9d 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -89,7 +89,7 @@ if(HAVE_QT) if(${_have_flag}) set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations) endif() -elseif(WIN32 AND NOT ARM) +elseif(HAVE_WIN32UI) list(APPEND highgui_srcs src/window_w32.cpp) elseif(HAVE_GTK) list(APPEND highgui_srcs src/window_gtk.cpp) diff --git a/modules/highgui/perf/perf_precomp.hpp b/modules/highgui/perf/perf_precomp.hpp index ec8a447..b43e038 100644 --- a/modules/highgui/perf/perf_precomp.hpp +++ b/modules/highgui/perf/perf_precomp.hpp @@ -21,8 +21,7 @@ defined(HAVE_QUICKTIME) || \ defined(HAVE_AVFOUNDATION) || \ /*defined(HAVE_OPENNI) || too specialized */ \ - defined(HAVE_FFMPEG) || \ - defined(WIN32) /* assume that we have ffmpeg */ + defined(HAVE_FFMPEG) # define BUILD_WITH_VIDEO_INPUT_SUPPORT 1 #else @@ -33,8 +32,7 @@ defined(HAVE_GSTREAMER) || \ defined(HAVE_QUICKTIME) || \ defined(HAVE_AVFOUNDATION) || \ - defined(HAVE_FFMPEG) || \ - defined(WIN32) /* assume that we have ffmpeg */ + defined(HAVE_FFMPEG) # define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1 #else # define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0 diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index 2c754ca..9befa7b 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -200,7 +200,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) capture = cvCreateCameraCapture_DShow (index); if (capture) return capture; - return NULL; break; #endif diff --git a/modules/highgui/src/cap_ffmpeg.cpp b/modules/highgui/src/cap_ffmpeg.cpp index 22caab8..669ebda 100644 --- a/modules/highgui/src/cap_ffmpeg.cpp +++ b/modules/highgui/src/cap_ffmpeg.cpp @@ -209,7 +209,7 @@ CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename) if( result->open( filename )) return result; delete result; -#if (defined WIN32 || defined _WIN32) && !defined _M_ARM +#ifdef HAVE_VFW return cvCreateFileCapture_VFW(filename); #else return 0; @@ -263,7 +263,7 @@ CvVideoWriter* cvCreateVideoWriter_FFMPEG_proxy( const char* filename, int fourc if( result->open( filename, fourcc, fps, frameSize, isColor != 0 )) return result; delete result; -#if (defined WIN32 || defined _WIN32) && !defined _M_ARM +#ifdef HAVE_VFW return cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, isColor); #else return 0; diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp index 64efbb9..afa0735 100644 --- a/modules/highgui/src/precomp.hpp +++ b/modules/highgui/src/precomp.hpp @@ -103,14 +103,6 @@ struct CvVideoWriter virtual bool writeFrame(const IplImage*) { return false; } }; -#if (defined WIN32 || defined _WIN32) && !defined _M_ARM -#define HAVE_VFW 1 - -/* uncomment to enable CMUCamera1394 fireware camera module */ -//#define HAVE_CMU1394 1 -#endif - - CvCapture * cvCreateCameraCapture_V4L( int index ); CvCapture * cvCreateCameraCapture_DC1394( int index ); CvCapture * cvCreateCameraCapture_DC1394_2( int index ); diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index 12816f3..6d29534 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -57,7 +57,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu #if defined (HAVE_QT) cvSetModeWindow_QT(name,prop_value); - #elif (defined WIN32 || defined _WIN32) && !defined _M_ARM + #elif defined(HAVE_WIN32UI) cvSetModeWindow_W32(name,prop_value); #elif defined (HAVE_GTK) cvSetModeWindow_GTK(name,prop_value); @@ -96,7 +96,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id) #if defined (HAVE_QT) return cvGetModeWindow_QT(name); - #elif (defined WIN32 || defined _WIN32) && !defined _M_ARM + #elif defined(HAVE_WIN32UI) return cvGetModeWindow_W32(name); #elif defined (HAVE_GTK) return cvGetModeWindow_GTK(name); @@ -113,7 +113,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id) #if defined (HAVE_QT) return cvGetPropWindow_QT(name); - #elif (defined WIN32 || defined _WIN32) && !defined _M_ARM + #elif defined(HAVE_WIN32UI) return cvGetPropWindowAutoSize_W32(name); #elif defined (HAVE_GTK) return cvGetPropWindowAutoSize_GTK(name); @@ -126,7 +126,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id) #if defined (HAVE_QT) return cvGetRatioWindow_QT(name); - #elif (defined WIN32 || defined _WIN32) && !defined _M_ARM + #elif defined(HAVE_WIN32UI) return cvGetRatioWindow_W32(name); #elif defined (HAVE_GTK) return cvGetRatioWindow_GTK(name); @@ -139,7 +139,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id) #if defined (HAVE_QT) return cvGetOpenGlProp_QT(name); - #elif (defined WIN32 || defined _WIN32) && !defined _M_ARM + #elif defined(HAVE_WIN32UI) return cvGetOpenGlProp_W32(name); #elif defined (HAVE_GTK) return cvGetOpenGlProp_GTK(name); @@ -450,7 +450,7 @@ int cv::createButton(const string&, ButtonCallback, void*, int , bool ) #endif -#if (defined WIN32 || defined _WIN32) && !defined _M_ARM // see window_w32.cpp +#if defined(HAVE_WIN32UI) // see window_w32.cpp #elif defined (HAVE_GTK) // see window_gtk.cpp #elif defined (HAVE_COCOA) // see window_carbon.cpp #elif defined (HAVE_CARBON) diff --git a/modules/highgui/test/test_ffmpeg.cpp b/modules/highgui/test/test_ffmpeg.cpp index 547060e..2bfd527 100644 --- a/modules/highgui/test/test_ffmpeg.cpp +++ b/modules/highgui/test/test_ffmpeg.cpp @@ -176,7 +176,7 @@ TEST(Highgui_Video, ffmpeg_image) { CV_FFmpegReadImageTest test; test.safe_run() #endif -#if defined(HAVE_FFMPEG) || ((defined(WIN32) || defined(_WIN32)) && !defined(_M_ARM)) +#if defined(HAVE_FFMPEG) //////////////////////////////// Parallel VideoWriters and VideoCaptures //////////////////////////////////// diff --git a/modules/highgui/test/test_gui.cpp b/modules/highgui/test/test_gui.cpp index e802f29..c2726a4 100644 --- a/modules/highgui/test/test_gui.cpp +++ b/modules/highgui/test/test_gui.cpp @@ -43,7 +43,7 @@ #include "test_precomp.hpp" #include "opencv2/highgui/highgui.hpp" -#if defined HAVE_GTK || defined HAVE_QT || ((defined WIN32 || defined _WIN32) && !_M_ARM) || defined HAVE_CARBON || defined HAVE_COCOA +#if defined HAVE_GTK || defined HAVE_QT || defined HAVE_WIN32UI || defined HAVE_CARBON || defined HAVE_COCOA using namespace cv; using namespace std; diff --git a/modules/highgui/test/test_precomp.hpp b/modules/highgui/test/test_precomp.hpp index bdf3f38..bbc6b41 100644 --- a/modules/highgui/test/test_precomp.hpp +++ b/modules/highgui/test/test_precomp.hpp @@ -47,9 +47,7 @@ defined(HAVE_QUICKTIME) || \ defined(HAVE_AVFOUNDATION) || \ /*defined(HAVE_OPENNI) || too specialized */ \ - defined(HAVE_FFMPEG) || \ - (defined(WIN32) && !defined(_M_ARM))/* assume that we have ffmpeg on x86 and no on ARM */ - + defined(HAVE_FFMPEG) # define BUILD_WITH_VIDEO_INPUT_SUPPORT 1 #else # define BUILD_WITH_VIDEO_INPUT_SUPPORT 0 @@ -59,8 +57,7 @@ defined(HAVE_GSTREAMER) || \ defined(HAVE_QUICKTIME) || \ defined(HAVE_AVFOUNDATION) || \ - defined(HAVE_FFMPEG) || \ - (defined(WIN32) && !defined(_M_ARM)) /* assume that we have ffmpeg */ + defined(HAVE_FFMPEG) # define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1 #else # define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0 -- 2.7.4