Fix MSVC build issues
authorAndrey Kamaev <andrey.kamaev@itseez.com>
Fri, 29 Mar 2013 20:47:22 +0000 (00:47 +0400)
committerAndrey Kamaev <andrey.kamaev@itseez.com>
Mon, 1 Apr 2013 11:24:34 +0000 (15:24 +0400)
modules/core/include/opencv2/core/core_c.h
modules/core/include/opencv2/core/matx.hpp
modules/core/include/opencv2/core/types.hpp
modules/core/include/opencv2/core/types_c.h
modules/ocl/src/haar.cpp
modules/ocl/src/matrix_operations.cpp
modules/ocl/src/moments.cpp
modules/ts/include/opencv2/ts/ts_perf.hpp
samples/gpu/super_resolution.cpp
samples/ocl/facedetect.cpp

index 2ae1d61..544f0c5 100644 (file)
 #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
 
index 7dddd8f..ea008c0 100644 (file)
@@ -257,10 +257,10 @@ public:
 /*!
  Utility methods
 */
-template<typename _Tp, int m> double determinant(const Matx<_Tp, m, m>& a);
-template<typename _Tp, int m, int n> double trace(const Matx<_Tp, m, n>& a);
-template<typename _Tp, int m, int n> double norm(const Matx<_Tp, m, n>& M);
-template<typename _Tp, int m, int n> double norm(const Matx<_Tp, m, n>& M, int normType);
+template<typename _Tp, int m> static double determinant(const Matx<_Tp, m, m>& a);
+template<typename _Tp, int m, int n> static double trace(const Matx<_Tp, m, n>& a);
+template<typename _Tp, int m, int n> static double norm(const Matx<_Tp, m, n>& M);
+template<typename _Tp, int m, int n> static double norm(const Matx<_Tp, m, n>& M, int normType);
 
 
 
@@ -399,7 +399,7 @@ public:
 /*!
  Utility methods
 */
-template<typename _Tp, int cn> Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v);
+template<typename _Tp, int cn> static Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v);
 
 
 
index 5111f36..8add1dc 100644 (file)
@@ -517,7 +517,7 @@ public:
     typedef _Tp                                        channel_type;
 
     enum { generic_type = 0,
-           depth        = DataType<channel_type>::value,
+           depth        = DataType<channel_type>::depth,
            channels     = 4,
            fmt          = DataType<channel_type>::fmt + ((channels - 1) << 8),
            type         = CV_MAKETYPE(depth, channels)
index 352e000..114cbba 100644 (file)
@@ -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) \
index 181dc73..18ac8b0 100644 (file)
@@ -931,10 +931,10 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS
         std::vector<float> 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++ )
         {
index 0e9b388..bc045bf 100644 (file)
@@ -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)
     //{
index 68fe3ce..51cde6f 100644 (file)
@@ -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;
index 2e333a0..c45f6d4 100644 (file)
@@ -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 <android/log.h>
index 3ab5ed0..bdd4b43 100644 (file)
@@ -47,7 +47,6 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name, bool useGpu)
     else
     {
         cerr << "Incorrect Optical Flow algorithm - " << name << endl;
-        exit(-1);
     }
 
     return Ptr<DenseOpticalFlowExt>();
@@ -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<DenseOpticalFlowExt> of = createOptFlow(optFlow, useGpu);
+    if (of.empty())
+        exit(-1);
+    superRes->set("opticalFlow", of);
 
     Ptr<FrameSource> frameSource;
     if (useGpu)
index 08f45f8..df6308c 100644 (file)
@@ -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 )