From 49b55a7245a5452e836aee76cf4237f0d90f97ee Mon Sep 17 00:00:00 2001 From: Sam Bromley Date: Thu, 26 Jul 2012 12:35:21 -0230 Subject: [PATCH 1/4] Protect check for _MSC_VER with #if defined. --- modules/core/include/opencv2/core/internal.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/core/include/opencv2/core/internal.hpp b/modules/core/include/opencv2/core/internal.hpp index 369921aff5..2fe56cd7d9 100644 --- a/modules/core/include/opencv2/core/internal.hpp +++ b/modules/core/include/opencv2/core/internal.hpp @@ -120,15 +120,15 @@ CV_INLINE IppiSize ippiSize(int width, int height) # else # define CV_SSSE3 0 # endif -# if defined __SSE4_1__ || _MSC_VER >= 1600 +# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1600) # include # define CV_SSE4_1 1 # endif -# if defined __SSE4_2__ || _MSC_VER >= 1600 +# if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1600) # include # define CV_SSE4_2 1 # endif -# if defined __AVX__ || _MSC_VER >= 1600 +# if defined __AVX__ || (defined _MSC_VER && _MSC_VER >= 1600) # include # define CV_AVX 1 # endif @@ -779,4 +779,4 @@ CV_EXPORTS bool icvCheckGlError(const char* file, const int line, const char* fu #endif //__cplusplus -#endif // __OPENCV_CORE_INTERNAL_HPP__ \ No newline at end of file +#endif // __OPENCV_CORE_INTERNAL_HPP__ From 966a652142267aab31b58453adc568c694324f92 Mon Sep 17 00:00:00 2001 From: Sam Bromley Date: Thu, 26 Jul 2012 12:36:21 -0230 Subject: [PATCH 2/4] Fix crash when polling for non-existent Kinects. If no Kinects are present, crash can result from stepping beyond end of device list. Now we check to ensure this does not happen. --- modules/highgui/src/cap_openni.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_openni.cpp b/modules/highgui/src/cap_openni.cpp index b440e0a02e..a95f2fd046 100644 --- a/modules/highgui/src/cap_openni.cpp +++ b/modules/highgui/src/cap_openni.cpp @@ -575,7 +575,12 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) // Chose device according to index xn::NodeInfoList::Iterator it = devicesList.Begin(); - for( int i = 0; i < index; ++i ) it++; + for( int i = 0; i < index && it!=devicesList.End(); ++i ) it++; + if ( it == devicesList.End() ) + { + std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Faile + return; + } xn::NodeInfo deviceNode = *it; status = context.CreateProductionTree( deviceNode, productionNode ); From fd98520d7830b061bfe8b72a161920c0a7fb1cb8 Mon Sep 17 00:00:00 2001 From: Sam Bromley Date: Thu, 26 Jul 2012 12:43:56 -0230 Subject: [PATCH 3/4] Protect check of CV_SSE4_2 with #if defined. --- modules/core/src/stat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index 3626a2a675..560ef54624 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -225,7 +225,7 @@ template <> int countNonZero_ (const uchar* src, int len) { int i=0, nz = 0; - #if CV_SSE4_2 + #if (defined CV_SSE4_2 && CV_SSE4_2) if(USE_SSE4_2)//5x-6x { __m128i pattern = _mm_setzero_si128 (); @@ -2012,4 +2012,4 @@ cvNorm( const void* imgA, const void* imgB, int normType, const void* maskarr ) cv::extractImageCOI(imgB, b); return !maskarr ? cv::norm(a, b, normType) : cv::norm(a, b, normType, mask); -} \ No newline at end of file +} From 8506ce06c19ce0005452f1efc887886d6894eb44 Mon Sep 17 00:00:00 2001 From: Sam Bromley Date: Thu, 26 Jul 2012 12:46:51 -0230 Subject: [PATCH 4/4] Fix missing remainder of line. --- modules/highgui/src/cap_openni.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/highgui/src/cap_openni.cpp b/modules/highgui/src/cap_openni.cpp index a95f2fd046..75aed56dce 100644 --- a/modules/highgui/src/cap_openni.cpp +++ b/modules/highgui/src/cap_openni.cpp @@ -44,7 +44,7 @@ #ifdef HAVE_OPENNI -#if TBB_INTERFACE_VERSION < 5000 +#if defined TBB_INTERFACE_VERSION && TBB_INTERFACE_VERSION < 5000 # undef HAVE_TBB #endif @@ -578,8 +578,8 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) for( int i = 0; i < index && it!=devicesList.End(); ++i ) it++; if ( it == devicesList.End() ) { - std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Faile - return; + std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Failed device with index " << index << std::endl; + return; } xn::NodeInfo deviceNode = *it;