From f2a02feffa582a850800174e9a520e2a4d730777 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 22 Aug 2012 03:59:05 +0400 Subject: [PATCH] Fix Windows build issues * No /arch:SSE3 in MSVC * Warnings fixed or suppressed --- 3rdparty/libtiff/CMakeLists.txt | 2 +- CMakeLists.txt | 8 ++--- modules/features2d/src/features2d_init.cpp | 2 +- modules/features2d/test/test_fast.cpp | 4 +-- .../features2d/test/test_nearestneighbors.cpp | 6 ++-- .../test_rotation_and_scale_invariance.cpp | 30 +++++++++---------- modules/gpu/perf/perf_imgproc.cpp | 18 +++++------ modules/gpu/perf/perf_labeling.cpp | 9 ++++-- modules/gpu/perf/perf_video.cpp | 2 +- samples/cpp/bagofwords_classification.cpp | 1 + samples/gpu/bgfg_segm.cpp | 6 ++-- samples/gpu/performance/tests.cpp | 4 +-- 12 files changed, 49 insertions(+), 43 deletions(-) diff --git a/3rdparty/libtiff/CMakeLists.txt b/3rdparty/libtiff/CMakeLists.txt index ed9d1c86b7..6dd7956f58 100644 --- a/3rdparty/libtiff/CMakeLists.txt +++ b/3rdparty/libtiff/CMakeLists.txt @@ -89,7 +89,7 @@ endif(WIN32) ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef -Wunused -Wsign-compare -Wcast-align -Wshadow -Wno-maybe-uninitialized -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast) -ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter /wd4100 /wd4244 /wd4706 /wd4127 /wd4701 /wd4018 /wd4267 /wd4306 /wd4305 /wd4312 /wd4311) +ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter /wd4100 /wd4244 /wd4706 /wd4127 /wd4701 /wd4018 /wd4267 /wd4306 /wd4305 /wd4312 /wd4311 /wd4703) if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") diff --git a/CMakeLists.txt b/CMakeLists.txt index c81cbd9dee..d893f1c74d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,11 +189,11 @@ OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX ) OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) ) OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) ) -OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) ) -OCV_OPTION(ENABLE_SSE2 "Enable SSE2 instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) ) -OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" ON IF (MSVC OR CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) ) +OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) ) +OCV_OPTION(ENABLE_SSE2 "Enable SSE2 instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) ) +OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" ON IF ((CV_ICC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) ) OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) ) -OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) ) +OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF ((CV_ICC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) ) OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) ) OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF ) OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF ) diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index e21b8d8021..c9abfefa9f 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -59,7 +59,7 @@ CV_INIT_ALGORITHM(BriefDescriptorExtractor, "Feature2D.BRIEF", CV_INIT_ALGORITHM(FastFeatureDetector, "Feature2D.FAST", obj.info()->addParam(obj, "threshold", obj.threshold); obj.info()->addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression); - obj.info()->addParam(obj, "type", obj.type, static_cast(FastFeatureDetector::TYPE_9_16))); + obj.info()->addParam(obj, "type", obj.type)); /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/features2d/test/test_fast.cpp b/modules/features2d/test/test_fast.cpp index 671e66d5f4..761abfcca3 100644 --- a/modules/features2d/test/test_fast.cpp +++ b/modules/features2d/test/test_fast.cpp @@ -75,8 +75,8 @@ void CV_FastTest::run( int ) vector keypoints1; vector keypoints2; - FAST(gray1, keypoints1, 30, type); - FAST(gray2, keypoints2, 30, type); + FAST(gray1, keypoints1, 30, true, type); + FAST(gray2, keypoints2, 30, true, type); for(size_t i = 0; i < keypoints1.size(); ++i) { diff --git a/modules/features2d/test/test_nearestneighbors.cpp b/modules/features2d/test/test_nearestneighbors.cpp index 8a0482218f..45131eff2e 100644 --- a/modules/features2d/test/test_nearestneighbors.cpp +++ b/modules/features2d/test/test_nearestneighbors.cpp @@ -200,7 +200,7 @@ int CV_KDTreeTest_CPP::checkGetPoins( const Mat& data ) int CV_KDTreeTest_CPP::checkFindBoxed() { - vector min( dims, minValue), max(dims, maxValue); + vector min( dims, static_cast(minValue)), max(dims, static_cast(maxValue)); vector indices; tr->findOrthoRange( min, max, indices ); // TODO check indices @@ -214,8 +214,8 @@ int CV_KDTreeTest_CPP::findNeighbors( Mat& points, Mat& neighbors ) const int emax = 20; Mat neighbors2( neighbors.size(), CV_32SC1 ); int j; - vector min(points.cols, minValue); - vector max(points.cols, maxValue); + vector min(points.cols, static_cast(minValue)); + vector max(points.cols, static_cast(maxValue)); for( int pi = 0; pi < points.rows; pi++ ) { // 1st way diff --git a/modules/features2d/test/test_rotation_and_scale_invariance.cpp b/modules/features2d/test/test_rotation_and_scale_invariance.cpp index d98431ba57..48dddd3eee 100644 --- a/modules/features2d/test/test_rotation_and_scale_invariance.cpp +++ b/modules/features2d/test/test_rotation_and_scale_invariance.cpp @@ -54,7 +54,7 @@ static Mat generateHomography(float angle) { // angle - rotation around Oz in degrees - float angleRadian = angle * CV_PI / 180.; + float angleRadian = static_cast(angle * CV_PI / 180); Mat H = Mat::eye(3, 3, CV_32FC1); H.at(0,0) = H.at(1,1) = std::cos(angleRadian); H.at(0,1) = -std::sin(angleRadian); @@ -69,8 +69,8 @@ Mat rotateImage(const Mat& srcImage, float angle, Mat& dstImage, Mat& dstMask) // angle - rotation around Oz in degrees float diag = std::sqrt(static_cast(srcImage.cols * srcImage.cols + srcImage.rows * srcImage.rows)); Mat LUShift = Mat::eye(3, 3, CV_32FC1); // left up - LUShift.at(0,2) = -srcImage.cols/2; - LUShift.at(1,2) = -srcImage.rows/2; + LUShift.at(0,2) = static_cast(-srcImage.cols/2); + LUShift.at(1,2) = static_cast(-srcImage.rows/2); Mat RDShift = Mat::eye(3, 3, CV_32FC1); // right down RDShift.at(0,2) = diag/2; RDShift.at(1,2) = diag/2; @@ -114,7 +114,7 @@ void scaleKeyPoints(const vector& src, vector& dst, float sc static float calcCirclesIntersectArea(const Point2f& p0, float r0, const Point2f& p1, float r1) { - float c = norm(p0 - p1), sqr_c = c * c; + float c = static_cast(norm(p0 - p1)), sqr_c = c * c; float sqr_r0 = r0 * r0; float sqr_r1 = r1 * r1; @@ -125,7 +125,7 @@ float calcCirclesIntersectArea(const Point2f& p0, float r0, const Point2f& p1, f float minR = std::min(r0, r1); float maxR = std::max(r0, r1); if(c + minR <= maxR) - return CV_PI * minR * minR; + return static_cast(CV_PI * minR * minR); float cos_halfA0 = (sqr_r0 + sqr_c - sqr_r1) / (2 * r0 * c); float cos_halfA1 = (sqr_r1 + sqr_c - sqr_r0) / (2 * r1 * c); @@ -133,15 +133,15 @@ float calcCirclesIntersectArea(const Point2f& p0, float r0, const Point2f& p1, f float A0 = 2 * acos(cos_halfA0); float A1 = 2 * acos(cos_halfA1); - return 0.5 * sqr_r0 * (A0 - sin(A0)) + - 0.5 * sqr_r1 * (A1 - sin(A1)); + return 0.5f * sqr_r0 * (A0 - sin(A0)) + + 0.5f * sqr_r1 * (A1 - sin(A1)); } static float calcIntersectRatio(const Point2f& p0, float r0, const Point2f& p1, float r1) { float intersectArea = calcCirclesIntersectArea(p0, r0, p1, r1); - float unionArea = CV_PI * (r0 * r0 + r1 * r1) - intersectArea; + float unionArea = static_cast(CV_PI) * (r0 * r0 + r1 * r1) - intersectArea; return intersectArea / unionArea; } @@ -160,7 +160,7 @@ void matchKeyPoints(const vector& keypoints0, const Mat& H, matches.clear(); vector usedMask(keypoints1.size(), 0); - for(size_t i0 = 0; i0 < keypoints0.size(); i0++) + for(int i0 = 0; i0 < static_cast(keypoints0.size()); i0++) { int nearestPointIndex = -1; float maxIntersectRatio = 0.f; @@ -176,7 +176,7 @@ void matchKeyPoints(const vector& keypoints0, const Mat& H, if(intersectRatio > maxIntersectRatio) { maxIntersectRatio = intersectRatio; - nearestPointIndex = i1; + nearestPointIndex = static_cast(i1); } } @@ -222,7 +222,7 @@ protected: const int maxAngle = 360, angleStep = 15; for(int angle = 0; angle < maxAngle; angle += angleStep) { - Mat H = rotateImage(image0, angle, image1, mask1); + Mat H = rotateImage(image0, static_cast(angle), image1, mask1); vector keypoints1; featureDetector->detect(image1, keypoints1, mask1); @@ -339,10 +339,10 @@ protected: const int maxAngle = 360, angleStep = 15; for(int angle = 0; angle < maxAngle; angle += angleStep) { - Mat H = rotateImage(image0, angle, image1, mask1); + Mat H = rotateImage(image0, static_cast(angle), image1, mask1); vector keypoints1; - rotateKeyPoints(keypoints0, H, angle, keypoints1); + rotateKeyPoints(keypoints0, H, static_cast(angle), keypoints1); Mat descriptors1; descriptorExtractor->compute(image1, keypoints1, descriptors1); @@ -457,7 +457,7 @@ protected: keyPointMatchesCount++; // Check does this inlier have consistent sizes - const float maxSizeDiff = 0.8;//0.9f; // grad + const float maxSizeDiff = 0.8f;//0.9f; // grad float size0 = keypoints0[matches[m].trainIdx].size; float size1 = osiKeypoints1[matches[m].queryIdx].size; CV_Assert(size0 > 0 && size1 > 0); @@ -545,7 +545,7 @@ protected: resize(image0, image1, Size(), 1./scale, 1./scale); vector keypoints1; - scaleKeyPoints(keypoints0, keypoints1, 1./scale); + scaleKeyPoints(keypoints0, keypoints1, 1.0f/scale); Mat descriptors1; descriptorExtractor->compute(image1, keypoints1, descriptors1); diff --git a/modules/gpu/perf/perf_imgproc.cpp b/modules/gpu/perf/perf_imgproc.cpp index 979aaa3723..f938ca239e 100644 --- a/modules/gpu/perf/perf_imgproc.cpp +++ b/modules/gpu/perf/perf_imgproc.cpp @@ -23,8 +23,8 @@ void generateMap(cv::Mat& map_x, cv::Mat& map_y, int remapMode) case HALF_SIZE: if (i > map_x.cols*0.25 && i < map_x.cols*0.75 && j > map_x.rows*0.25 && j < map_x.rows*0.75) { - map_x.at(j,i) = 2 * (i - map_x.cols * 0.25) + 0.5; - map_y.at(j,i) = 2 * (j - map_x.rows * 0.25) + 0.5; + map_x.at(j,i) = 2 * (i - map_x.cols * 0.25f) + 0.5f; + map_y.at(j,i) = 2 * (j - map_x.rows * 0.25f) + 0.5f; } else { @@ -33,16 +33,16 @@ void generateMap(cv::Mat& map_x, cv::Mat& map_y, int remapMode) } break; case UPSIDE_DOWN: - map_x.at(j,i) = i; - map_y.at(j,i) = map_x.rows - j; + map_x.at(j,i) = static_cast(i); + map_y.at(j,i) = static_cast(map_x.rows - j); break; case REFLECTION_X: - map_x.at(j,i) = map_x.cols - i; - map_y.at(j,i) = j; + map_x.at(j,i) = static_cast(map_x.cols - i); + map_y.at(j,i) = static_cast(j); break; case REFLECTION_BOTH: - map_x.at(j,i) = map_x.cols - i; - map_y.at(j,i) = map_x.rows - j; + map_x.at(j,i) = static_cast(map_x.cols - i); + map_y.at(j,i) = static_cast(map_x.rows - j); break; } // end of switch } @@ -1619,7 +1619,7 @@ PERF_TEST_P(Sz_DoSort, ImgProc_HoughLines, Combine(GPU_TYPICAL_MAT_SIZES, Bool() const bool doSort = GET_PARAM(1); const float rho = 1.0f; - const float theta = CV_PI / 180.0f; + const float theta = static_cast(CV_PI / 180.0); const int threshold = 300; cv::RNG rng(123456789); diff --git a/modules/gpu/perf/perf_labeling.cpp b/modules/gpu/perf/perf_labeling.cpp index f17dd7d0af..bbab5ecfa4 100644 --- a/modules/gpu/perf/perf_labeling.cpp +++ b/modules/gpu/perf/perf_labeling.cpp @@ -31,6 +31,11 @@ struct GreedyLabeling int d = a - b; return lo <= d && d <= hi; } + + private: + InInterval& operator=(const InInterval&); + + }; GreedyLabeling(cv::Mat img) @@ -45,7 +50,7 @@ struct GreedyLabeling int cc = -1; int* dist_labels = (int*)labels.data; - int pitch = labels.step1(); + int pitch = static_cast(labels.step1()); unsigned char* source = (unsigned char*)image.data; int width = image.cols; @@ -82,7 +87,7 @@ struct GreedyLabeling *top++ = dot::make(p.x, p.y + 1); //top - if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()])) + if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-static_cast(image.step1())])) *top++ = dot::make(p.x, p.y - 1); p = *--top; diff --git a/modules/gpu/perf/perf_video.cpp b/modules/gpu/perf/perf_video.cpp index 7faea0b880..8346d25f42 100644 --- a/modules/gpu/perf/perf_video.cpp +++ b/modules/gpu/perf/perf_video.cpp @@ -427,7 +427,7 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576. { string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); int cn = GET_PARAM(1); - double learningRate = GET_PARAM(2); + float learningRate = static_cast(GET_PARAM(2)); cv::VideoCapture cap(inputFile); ASSERT_TRUE(cap.isOpened()); diff --git a/samples/cpp/bagofwords_classification.cpp b/samples/cpp/bagofwords_classification.cpp index 559e77bfcf..071c2a1733 100644 --- a/samples/cpp/bagofwords_classification.cpp +++ b/samples/cpp/bagofwords_classification.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #if defined WIN32 || defined _WIN32 #define WIN32_LEAN_AND_MEAN diff --git a/samples/gpu/bgfg_segm.cpp b/samples/gpu/bgfg_segm.cpp index 7c5e148f77..4e4c52096c 100644 --- a/samples/gpu/bgfg_segm.cpp +++ b/samples/gpu/bgfg_segm.cpp @@ -86,7 +86,7 @@ int main(int argc, const char** argv) break; case MOG: - mog(d_frame, d_fgmask, 0.01); + mog(d_frame, d_fgmask, 0.01f); break; case MOG2: @@ -127,7 +127,7 @@ int main(int argc, const char** argv) break; case MOG: - mog(d_frame, d_fgmask, 0.01); + mog(d_frame, d_fgmask, 0.01f); mog.getBackgroundImage(d_bgimg); break; @@ -162,7 +162,7 @@ int main(int argc, const char** argv) if (!bgimg.empty()) imshow("mean background image", bgimg); - char key = waitKey(30); + int key = waitKey(30); if (key == 27) break; } diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index aefd9572f6..e117202838 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -1341,7 +1341,7 @@ TEST(MOG) cv::gpu::MOG_GPU d_mog; cv::gpu::GpuMat d_foreground; - d_mog(d_frame, d_foreground, 0.01); + d_mog(d_frame, d_foreground, 0.01f); while (!TestSystem::instance().stop()) { @@ -1350,7 +1350,7 @@ TEST(MOG) TestSystem::instance().gpuOn(); - d_mog(d_frame, d_foreground, 0.01); + d_mog(d_frame, d_foreground, 0.01f); TestSystem::instance().gpuOff(); } -- GitLab