From d0ec65e80c2d6a7b57da9aafa3acd40ea2a66204 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 22 Oct 2012 18:19:32 +0400 Subject: [PATCH 1/4] Fix linux build warning --- modules/python/src2/cv2.cv.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/python/src2/cv2.cv.hpp b/modules/python/src2/cv2.cv.hpp index 0207189a1a..09d3c47232 100644 --- a/modules/python/src2/cv2.cv.hpp +++ b/modules/python/src2/cv2.cv.hpp @@ -3829,8 +3829,9 @@ static int zero = 0; coeff_usage = CV_VALUE; \ else if ((length == alpha.count) && (alpha.count == beta.count) && (beta.count == gamma.count)) \ coeff_usage = CV_ARRAY; \ - else \ - return (PyObject*)failmsg("SnakeImage weights invalid"); \ + else { \ + failmsg("SnakeImage weights invalid"); \ + return (PyObject*)0; } \ cvSnakeImage(image, points, length, a, b, g, coeff_usage, win, criteria, calc_gradient); \ } while (0) From 15076f923238d606adc8a20d0de2e738f0dcf829 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 22 Oct 2012 18:39:56 +0400 Subject: [PATCH 2/4] Fix implementation of PCA overload with retained variance parameter --- modules/core/src/matmul.cpp | 4 ++-- modules/core/test/test_mat.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index af8c575819..9b3868505a 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -2813,7 +2813,7 @@ PCA::PCA(InputArray data, InputArray _mean, int flags, int maxComponents) PCA::PCA(InputArray data, InputArray _mean, int flags, double retainedVariance) { - operator()(data, _mean, flags, retainedVariance); + computeVar(data, _mean, flags, retainedVariance); } PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComponents) @@ -3077,7 +3077,7 @@ void cv::PCAComputeVar(InputArray data, InputOutputArray mean, OutputArray eigenvectors, double retainedVariance) { PCA pca; - pca(data, mean, 0, retainedVariance); + pca.computeVar(data, mean, 0, retainedVariance); pca.mean.copyTo(mean); pca.eigenvectors.copyTo(eigenvectors); } diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 8c72789b06..514b587d75 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -426,7 +426,7 @@ protected: } // 3. check C++ PCA w/retainedVariance - cPCA( rPoints.t(), Mat(), CV_PCA_DATA_AS_COL, retainedVariance ); + cPCA.computeVar( rPoints.t(), Mat(), CV_PCA_DATA_AS_COL, retainedVariance ); diffPrjEps = 1, diffBackPrjEps = 1; Mat rvPrjTestPoints = cPCA.project(rTestPoints.t()); From 40030d2ca038b1a5b446a023ecb0700ee5d5de83 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 22 Oct 2012 18:46:26 +0400 Subject: [PATCH 3/4] Fix windows build warnings --- modules/core/include/opencv2/core/operations.hpp | 9 +++++++++ modules/core/src/parallel.cpp | 4 ++-- modules/flann/src/miniflann.cpp | 2 +- modules/imgproc/src/color.cpp | 12 ++++++------ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 3d2812ba52..ae279a2e05 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -86,6 +86,11 @@ #include +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4127) //conditional expression is constant +#endif + namespace cv { @@ -3950,5 +3955,9 @@ template inline void AlgorithmInfo::addParam(Algorithm& algo, cons } +#ifdef _MSC_VER +# pragma warning(pop) +#endif + #endif // __cplusplus #endif diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index c31edede85..014b107106 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -362,8 +362,8 @@ void cv::setNumThreads( int threads ) else if (pplScheduler == 0 || 1 + pplScheduler->GetNumberOfVirtualProcessors() != (unsigned int)threads) { pplScheduler = Concurrency::Scheduler::Create(Concurrency::SchedulerPolicy(2, - Concurrency::PolicyElementKey::MinConcurrency, threads-1, - Concurrency::PolicyElementKey::MaxConcurrency, threads-1)); + Concurrency::MinConcurrency, threads-1, + Concurrency::MaxConcurrency, threads-1)); } #endif diff --git a/modules/flann/src/miniflann.cpp b/modules/flann/src/miniflann.cpp index 7d1bce4c08..3747102728 100644 --- a/modules/flann/src/miniflann.cpp +++ b/modules/flann/src/miniflann.cpp @@ -500,7 +500,7 @@ int runRadiusSearch_(void* index, const Mat& query, Mat& indices, Mat& dists, ::cvflann::Matrix _dists((DistanceType*)dists.data, dists.rows, dists.cols); return ((IndexType*)index)->radiusSearch(_query, _indices, _dists, - saturate_cast(radius), + saturate_cast(radius), (const ::cvflann::SearchParams&)get_params(params)); } diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 10fa86788d..e85acea3f3 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -1387,8 +1387,8 @@ struct RGB2Lab_f C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8]; n *= 3; - static const float _1_3 = 1.0 / 3.0; - static const double _a = 16.0 / 116; + static const float _1_3 = 1.0f / 3.0f; + static const float _a = 16.0f / 116.0f; for (i = 0; i < n; i += 3, src += scn ) { float R = clip(src[0]); @@ -1409,11 +1409,11 @@ struct RGB2Lab_f float Y = R*C3 + G*C4 + B*C5; float Z = R*C6 + G*C7 + B*C8; - float FX = X > 0.008856 ? pow(X, _1_3) : (7.787f * X + _a); - float FY = Y > 0.008856 ? pow(Y, _1_3) : (7.787f * Y + _a); - float FZ = Z > 0.008856 ? pow(Z, _1_3) : (7.787f * Z + _a); + float FX = X > 0.008856f ? pow(X, _1_3) : (7.787f * X + _a); + float FY = Y > 0.008856f ? pow(Y, _1_3) : (7.787f * Y + _a); + float FZ = Z > 0.008856f ? pow(Z, _1_3) : (7.787f * Z + _a); - float L = Y > 0.008856 ? (116.f * FY - 16.f) : (903.3 * Y); + float L = Y > 0.008856f ? (116.f * FY - 16.f) : (903.3f * Y); float a = 500.f * (FX - FY); float b = 200.f * (FY - FZ); From 2e91405833668d914a0d35b7ca45172ef9bee6e3 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Mon, 22 Oct 2012 19:13:29 +0400 Subject: [PATCH 4/4] Fix OS X build warnings --- cmake/OpenCVPCHSupport.cmake | 18 ++++++++++++++---- modules/contrib/src/rgbdodometry.cpp | 3 +++ modules/highgui/src/cap_qtkit.mm | 6 ++++++ modules/highgui/src/grfmt_exr.cpp | 4 ++++ modules/highgui/src/grfmt_exr.hpp | 4 ++++ modules/highgui/src/window_cocoa.mm | 6 ++++-- modules/legacy/src/_kdtree.hpp | 27 +++++++++++++-------------- modules/legacy/src/dpstereo.cpp | 2 +- modules/legacy/src/testseq.cpp | 6 +++--- 9 files changed, 52 insertions(+), 24 deletions(-) diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake index 290dbd8f66..fac6bd409b 100644 --- a/cmake/OpenCVPCHSupport.cmake +++ b/cmake/OpenCVPCHSupport.cmake @@ -182,10 +182,20 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use ) _PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn}) #MESSAGE("Add flags ${_target_cflags} to ${_targetName} " ) - SET_TARGET_PROPERTIES(${_targetName} - PROPERTIES - COMPILE_FLAGS ${_target_cflags} - ) + + GET_TARGET_PROPERTY(_sources ${_targetName} SOURCES) + FOREACH(src ${_sources}) + if(NOT "${src}" MATCHES "\\.mm$") + get_source_file_property(_flags "${src}" COMPILE_FLAGS) + if(_flags) + set(_flags "${_flags} ${_target_cflags}") + else() + set(_flags "${_target_cflags}") + endif() + + set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${_flags}") + endif() + ENDFOREACH() ADD_CUSTOM_TARGET(pch_Generate_${_targetName} DEPENDS ${_pch_output_to_use} diff --git a/modules/contrib/src/rgbdodometry.cpp b/modules/contrib/src/rgbdodometry.cpp index 1c80e9c55d..4e9d8c4df9 100644 --- a/modules/contrib/src/rgbdodometry.cpp +++ b/modules/contrib/src/rgbdodometry.cpp @@ -59,6 +59,9 @@ # ifdef ANDROID template Scalar log2(Scalar v) { using std::log; return log(v)/log(Scalar(2)); } # endif +# if defined __GNUC__ && defined __APPLE__ +# pragma GCC diagnostic ignored "-Wshadow" +# endif # include # include #endif diff --git a/modules/highgui/src/cap_qtkit.mm b/modules/highgui/src/cap_qtkit.mm index 783d0d1576..c7afffa075 100644 --- a/modules/highgui/src/cap_qtkit.mm +++ b/modules/highgui/src/cap_qtkit.mm @@ -503,6 +503,9 @@ bool CvCaptureCAM::setProperty(int property_id, double value) { didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection { + (void)captureOutput; + (void)sampleBuffer; + (void)connection; CVBufferRetain(videoFrame); CVImageBufferRef imageBufferToRelease = mCurrentImageBuffer; @@ -519,6 +522,9 @@ bool CvCaptureCAM::setProperty(int property_id, double value) { - (void)captureOutput:(QTCaptureOutput *)captureOutput didDropVideoFrameWithSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection { + (void)captureOutput; + (void)sampleBuffer; + (void)connection; cout << "Camera dropped frame!" << endl; } diff --git a/modules/highgui/src/grfmt_exr.cpp b/modules/highgui/src/grfmt_exr.cpp index ffae129662..c29f4ba36e 100644 --- a/modules/highgui/src/grfmt_exr.cpp +++ b/modules/highgui/src/grfmt_exr.cpp @@ -48,6 +48,10 @@ # pragma warning( disable: 4100 4244 4267 ) #endif +#if defined __GNUC__ && defined __APPLE__ +# pragma GCC diagnostic ignored "-Wshadow" +#endif + #include #include #include diff --git a/modules/highgui/src/grfmt_exr.hpp b/modules/highgui/src/grfmt_exr.hpp index 9c8c609d00..b9467c6d26 100644 --- a/modules/highgui/src/grfmt_exr.hpp +++ b/modules/highgui/src/grfmt_exr.hpp @@ -45,6 +45,10 @@ #ifdef HAVE_OPENEXR +#if defined __GNUC__ && defined __APPLE__ +# pragma GCC diagnostic ignored "-Wshadow" +#endif + #include #include #include diff --git a/modules/highgui/src/window_cocoa.mm b/modules/highgui/src/window_cocoa.mm index 886fde9339..d3a68107fc 100644 --- a/modules/highgui/src/window_cocoa.mm +++ b/modules/highgui/src/window_cocoa.mm @@ -136,7 +136,7 @@ static bool wasInitialized = false; } }*/ -CV_IMPL int cvInitSystem( int argc, char** argv) +CV_IMPL int cvInitSystem( int , char** ) { //cout << "cvInitSystem" << endl; wasInitialized = true; @@ -159,7 +159,7 @@ CV_IMPL int cvInitSystem( int argc, char** argv) return 0; } -CVWindow *cvGetWindow(const char *name) { +static CVWindow *cvGetWindow(const char *name) { //cout << "cvGetWindow" << endl; NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init]; NSString *cvname = [NSString stringWithFormat:@"%s", name]; @@ -614,6 +614,7 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value ) @synthesize status; - (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags { + (void)event; //cout << "cvSendMouseEvent" << endl; NSPoint mp = [NSEvent mouseLocation]; //NSRect visible = [[self contentView] frame]; @@ -924,6 +925,7 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value ) } - (void)sliderChanged:(NSNotification *)notification { + (void)notification; int pos = [slider intValue]; if(value) *value = pos; diff --git a/modules/legacy/src/_kdtree.hpp b/modules/legacy/src/_kdtree.hpp index ba9097a44e..48925eedae 100644 --- a/modules/legacy/src/_kdtree.hpp +++ b/modules/legacy/src/_kdtree.hpp @@ -169,7 +169,7 @@ private: __instype *split = median; for (; split != last && deref(ctor(*split), dim) == - deref(ctor(*median), dim); ++split); + deref(ctor(*median), dim); ++split) {} if (split == last) { // leaf int nexti = -1; @@ -387,9 +387,8 @@ public: // ret_nn_pq is an array containing the (at most) k nearest neighbors // (see bbf_nn structure def above). template < class __desctype > - int find_nn_bbf(const __desctype * d, - int k, int emax, - bbf_nn_pqueue & ret_nn_pq) const { + int find_nn_bbf(const __desctype * d, int k, int emax, bbf_nn_pqueue & ret_nn_pq) const + { assert(k > 0); ret_nn_pq.clear(); @@ -400,7 +399,8 @@ public: // iterate while queue non-empty and emax>0 tmp_pq.clear(); tmp_pq.push_back(bbf_node(root_node, 0)); - while (tmp_pq.size() && emax > 0) { + while (tmp_pq.size() && emax > 0) + { // from node nearest query point d, run to leaf std::pop_heap(tmp_pq.begin(), tmp_pq.end()); @@ -408,18 +408,17 @@ public: tmp_pq.erase(tmp_pq.end() - 1); int i; - for (i = bbf.node; - i != -1 && nodes[i].dim >= 0; - i = bbf_branch(i, d, tmp_pq)); + for (i = bbf.node; i != -1 && nodes[i].dim >= 0; i = bbf_branch(i, d, tmp_pq)) {} - if (i != -1) { + if (i != -1) + { - // add points in leaf/bin to ret_nn_pq - do { - bbf_new_nn(ret_nn_pq, k, d, nodes[i].value); - } while (-1 != (i = nodes[i].right)); + // add points in leaf/bin to ret_nn_pq + do { + bbf_new_nn(ret_nn_pq, k, d, nodes[i].value); + } while (-1 != (i = nodes[i].right)); - --emax; + --emax; } } diff --git a/modules/legacy/src/dpstereo.cpp b/modules/legacy/src/dpstereo.cpp index 1c6881e894..a55e1cafbb 100644 --- a/modules/legacy/src/dpstereo.cpp +++ b/modules/legacy/src/dpstereo.cpp @@ -414,7 +414,7 @@ static void icvFindStereoCorrespondenceByBirchfieldDP( uchar* src1, uchar* src2, for( x = 1; x < imgW; x++ ) { i = x - 1; - for( ; x < imgW && dest[y*widthStep+x] == dest[y*widthStep+x-1]; x++ ); + for( ; x < imgW && dest[y*widthStep+x] == dest[y*widthStep+x-1]; x++ ) {} s = x - i; for( ; i < x; i++ ) { diff --git a/modules/legacy/src/testseq.cpp b/modules/legacy/src/testseq.cpp index 37e19f79fd..d3521a5ae2 100644 --- a/modules/legacy/src/testseq.cpp +++ b/modules/legacy/src/testseq.cpp @@ -633,7 +633,7 @@ static CvTestSeqElem* icvTestSeqReadElemOne(CvTestSeq_* pTS, CvFileStorage* fs, for(i0=0, i1=1; i1i0); @@ -779,7 +779,7 @@ static CvTestSeqElem* icvTestSeqReadElemAll(CvTestSeq_* pTS, CvFileStorage* fs, } /* Find last element: */ - for(pElemLast=pElemNew;pElemLast && pElemLast->next;pElemLast= pElemLast->next); + for(pElemLast=pElemNew;pElemLast && pElemLast->next;pElemLast= pElemLast->next) {} } /* Next element. */ } /* Read all element in sequence. */ @@ -842,7 +842,7 @@ CvTestSeq* cvCreateTestSeq(char* pConfigfile, char** videos, int numvideo, float else { CvTestSeqElem* p = NULL; - for(p=pTS->pElemList;p->next;p=p->next); + for(p=pTS->pElemList;p->next;p=p->next) {} p->next = pElemNew; } } /* Read all videos. */