From 71e43852ce220ca12347e27d222ab037bfc9f365 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Sat, 30 Mar 2013 00:47:22 +0400 Subject: [PATCH] Fix MSVC build issues --- modules/core/include/opencv2/core/core_c.h | 9 +++++++++ modules/core/include/opencv2/core/matx.hpp | 10 +++++----- modules/core/include/opencv2/core/types.hpp | 2 +- modules/core/include/opencv2/core/types_c.h | 6 +++--- modules/ocl/src/haar.cpp | 10 ++++------ modules/ocl/src/matrix_operations.cpp | 2 +- modules/ocl/src/moments.cpp | 2 +- modules/ts/include/opencv2/ts/ts_perf.hpp | 13 +++++++++---- samples/gpu/super_resolution.cpp | 7 +++++-- samples/ocl/facedetect.cpp | 2 +- 10 files changed, 39 insertions(+), 24 deletions(-) diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index 2ae1d6176f..544f0c5a80 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -47,6 +47,15 @@ #include "opencv2/core/types_c.h" #ifdef __cplusplus +#ifdef _MSC_VER +/* disable warning C4190: 'function' has C-linkage specified, but returns UDT 'typename' + which is incompatible with C + + It is OK to disable it because we only extend few plain structures with + C++ construrtors for simpler interoperability with C++ API of the library +*/ +# pragma warning(disable:4190) +#endif extern "C" { #endif diff --git a/modules/core/include/opencv2/core/matx.hpp b/modules/core/include/opencv2/core/matx.hpp index 7dddd8f9c1..ea008c0713 100644 --- a/modules/core/include/opencv2/core/matx.hpp +++ b/modules/core/include/opencv2/core/matx.hpp @@ -257,10 +257,10 @@ public: /*! Utility methods */ -template double determinant(const Matx<_Tp, m, m>& a); -template double trace(const Matx<_Tp, m, n>& a); -template double norm(const Matx<_Tp, m, n>& M); -template double norm(const Matx<_Tp, m, n>& M, int normType); +template static double determinant(const Matx<_Tp, m, m>& a); +template static double trace(const Matx<_Tp, m, n>& a); +template static double norm(const Matx<_Tp, m, n>& M); +template static double norm(const Matx<_Tp, m, n>& M, int normType); @@ -399,7 +399,7 @@ public: /*! Utility methods */ -template Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v); +template static Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v); diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 5111f36322..8add1dc2f1 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -517,7 +517,7 @@ public: typedef _Tp channel_type; enum { generic_type = 0, - depth = DataType::value, + depth = DataType::depth, channels = 4, fmt = DataType::fmt + ((channels - 1) << 8), type = CV_MAKETYPE(depth, channels) diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index 352e000d4a..114cbba352 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -267,7 +267,7 @@ CV_INLINE double cvRandReal( CvRNG* rng ) #define IPL_BORDER_REFLECT 2 #define IPL_BORDER_WRAP 3 -typedef struct _IplImage +typedef struct CV_EXPORTS _IplImage { int nSize; /* sizeof(IplImage) */ int ID; /* version (=0)*/ @@ -558,7 +558,7 @@ CV_INLINE int cvIplDepth( int type ) #define CV_MAX_DIM 32 #define CV_MAX_DIM_HEAP 1024 -typedef struct CvMatND +typedef struct CV_EXPORTS CvMatND { int type; int dims; @@ -626,7 +626,7 @@ typedef struct CV_EXPORTS CvSparseMat CvSparseMat; #ifdef __cplusplus - CvSparseMat* cvCreateSparseMat(const cv::SparseMat& m); + CV_EXPORTS CvSparseMat* cvCreateSparseMat(const cv::SparseMat& m); #endif #define CV_IS_SPARSE_MAT_HDR(mat) \ diff --git a/modules/ocl/src/haar.cpp b/modules/ocl/src/haar.cpp index 181dc73590..18ac8b0949 100644 --- a/modules/ocl/src/haar.cpp +++ b/modules/ocl/src/haar.cpp @@ -931,10 +931,10 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS std::vector scalev; for(factor = 1.f;; factor *= scaleFactor) { - CvSize winSize = { cvRound(winSize0.width * factor), cvRound(winSize0.height * factor) }; + CvSize winSize( cvRound(winSize0.width * factor), cvRound(winSize0.height * factor) ); sz.width = cvRound( gimg.cols / factor ) + 1; sz.height = cvRound( gimg.rows / factor ) + 1; - CvSize sz1 = { sz.width - winSize0.width - 1, sz.height - winSize0.height - 1 }; + CvSize sz1( sz.width - winSize0.width - 1, sz.height - winSize0.height - 1 ); if( sz1.width <= 0 || sz1.height <= 0 ) break; @@ -1158,9 +1158,7 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS cvRound(factor * winsize0.height) < gimg.rows - 10; n_factors++, factor *= scaleFactor ) { - CvSize winSize = { cvRound( winsize0.width * factor ), - cvRound( winsize0.height * factor ) - }; + CvSize winSize( cvRound( winsize0.width * factor ), cvRound( winsize0.height * factor ) ); if( winSize.width < minSize.width || winSize.height < minSize.height ) { continue; @@ -1320,7 +1318,7 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS if( findBiggestObject && rectList.size() ) { - CvAvgComp result_comp = {{0, 0, 0, 0}, 0}; + CvAvgComp result_comp = {CvRect(), 0}; for( size_t i = 0; i < rectList.size(); i++ ) { diff --git a/modules/ocl/src/matrix_operations.cpp b/modules/ocl/src/matrix_operations.cpp index 0e9b3884db..bc045bfda6 100644 --- a/modules/ocl/src/matrix_operations.cpp +++ b/modules/ocl/src/matrix_operations.cpp @@ -927,7 +927,7 @@ void cv::ocl::oclMat::createEx(int _rows, int _cols, int _type, DevMemRW rw_type { clCxt = Context::getContext(); /* core logic */ - _type &= TYPE_MASK; + _type &= Mat::TYPE_MASK; //download_channels = CV_MAT_CN(_type); //if(download_channels==3) //{ diff --git a/modules/ocl/src/moments.cpp b/modules/ocl/src/moments.cpp index 68fe3ce098..51cde6fd88 100644 --- a/modules/ocl/src/moments.cpp +++ b/modules/ocl/src/moments.cpp @@ -265,7 +265,7 @@ static void ocl_cvMoments( const void* array, CvMoments* mom, int binary ) if( size.width <= 0 || size.height <= 0 ) return; - cv::Mat src0(mat); + cv::Mat src0 = cv::cvarrToMat(mat); cv::ocl::oclMat src(src0); cv::Size tileSize; int blockx,blocky; diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index 2e333a020e..c45f6d4af9 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -1,13 +1,18 @@ #ifndef __OPENCV_TS_PERF_HPP__ #define __OPENCV_TS_PERF_HPP__ +#ifdef HAVE_CVCONFIG_H +# include "cvconfig.h" +#endif +#ifndef GTEST_CREATE_SHARED_LIBRARY +# ifdef BUILD_SHARED_LIBS +# define GTEST_LINKED_AS_SHARED_LIBRARY 1 +# endif +#endif + #include "opencv2/core.hpp" #include "ts_gtest.h" -#ifdef HAVE_TBB -#include "tbb/task_scheduler_init.h" -#endif - #if !(defined(LOGD) || defined(LOGI) || defined(LOGW) || defined(LOGE)) # if defined(ANDROID) && defined(USE_ANDROID_LOGGING) # include diff --git a/samples/gpu/super_resolution.cpp b/samples/gpu/super_resolution.cpp index 3ab5ed062e..bdd4b43c54 100644 --- a/samples/gpu/super_resolution.cpp +++ b/samples/gpu/super_resolution.cpp @@ -47,7 +47,6 @@ static Ptr createOptFlow(const string& name, bool useGpu) else { cerr << "Incorrect Optical Flow algorithm - " << name << endl; - exit(-1); } return Ptr(); @@ -90,7 +89,11 @@ int main(int argc, const char* argv[]) superRes->set("scale", scale); superRes->set("iterations", iterations); superRes->set("temporalAreaRadius", temporalAreaRadius); - superRes->set("opticalFlow", createOptFlow(optFlow, useGpu)); + + Ptr of = createOptFlow(optFlow, useGpu); + if (of.empty()) + exit(-1); + superRes->set("opticalFlow", of); Ptr frameSource; if (useGpu) diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index 08f45f8853..df6308cb9e 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -114,7 +114,7 @@ int main( int argc, const char** argv ) for(;;) { IplImage* iplImg = cvQueryFrame( capture ); - frame = iplImg; + frame = cv::cvarrToMat(iplImg); if( frame.empty() ) break; if( iplImg->origin == IPL_ORIGIN_TL )