From 4985c1b632d6d25fccbe946120036f5a75b26362 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Fri, 16 Mar 2012 21:21:04 +0000 Subject: [PATCH] fixed hundreds of warnings from MSVC 2010. --- apps/traincascade/HOGfeatures.h | 4 +- apps/traincascade/boost.cpp | 4 +- modules/calib3d/perf/perf_pnp.cpp | 4 +- modules/calib3d/src/solvepnp.cpp | 3 -- modules/calib3d/test/test_homography.cpp | 41 +++++++++--------- modules/calib3d/test/test_solvepnp_ransac.cpp | 2 +- .../contrib/include/opencv2/contrib/contrib.hpp | 13 +++--- modules/contrib/src/gencolors.cpp | 10 ++--- modules/contrib/src/rgbdodometry.cpp | 28 ++++++------- modules/core/include/opencv2/core/core_c.h | 6 +-- modules/core/include/opencv2/core/operations.hpp | 12 +++--- modules/core/perf/perf_math.cpp | 2 +- modules/core/src/arithm.cpp | 10 ++--- modules/core/src/cmdparser.cpp | 6 +-- modules/core/src/datastructs.cpp | 12 +++--- modules/core/src/persistence.cpp | 1 + modules/core/test/test_countnonzero.cpp | 23 ++++------ modules/core/test/test_eigen.cpp | 16 +++---- modules/features2d/src/fast.cpp | 10 ++--- modules/features2d/src/matchers.cpp | 8 ++-- modules/features2d/src/mser.cpp | 8 ++-- modules/features2d/src/orb.cpp | 9 ++-- modules/features2d/src/stardetector.cpp | 2 +- modules/flann/include/opencv2/flann/ground_truth.h | 4 +- .../opencv2/flann/hierarchical_clustering_index.h | 8 ++-- .../flann/include/opencv2/flann/index_testing.h | 2 +- .../include/opencv2/flann/kdtree_single_index.h | 12 +++--- modules/flann/include/opencv2/flann/kmeans_index.h | 2 +- modules/flann/include/opencv2/flann/linear_index.h | 2 +- modules/flann/include/opencv2/flann/lsh_index.h | 8 ++-- modules/flann/include/opencv2/flann/lsh_table.h | 10 ++--- modules/flann/include/opencv2/flann/nn_index.h | 4 +- modules/flann/include/opencv2/flann/sampling.h | 4 +- modules/flann/src/flann.cpp | 4 ++ modules/flann/src/precomp.hpp | 4 ++ modules/highgui/src/cap.cpp | 1 + modules/highgui/src/cap_vfw.cpp | 1 + modules/highgui/src/grfmt_jpeg.cpp | 4 ++ modules/highgui/test/test_positioning.cpp | 2 +- modules/imgproc/perf/perf_filter2d.cpp | 2 +- modules/imgproc/src/color.cpp | 17 ++++---- modules/imgproc/src/gabor.cpp | 4 +- modules/imgproc/src/geometry.cpp | 6 +-- modules/imgproc/src/morph.cpp | 6 +-- modules/imgproc/src/phasecorr.cpp | 11 ++--- modules/imgproc/src/thresh.cpp | 4 +- modules/imgproc/test/test_boundingrect.cpp | 2 +- modules/legacy/include/opencv2/legacy/legacy.hpp | 4 +- modules/legacy/src/features2d.cpp | 4 +- modules/nonfree/src/sift.cpp | 21 +++++----- modules/nonfree/src/surf.cpp | 11 ++--- modules/nonfree/test/test_detectors.cpp | 2 +- modules/objdetect/src/latentsvmdetector.cpp | 2 +- modules/objdetect/src/linemod.cpp | 2 +- .../opencv2/stitching/detail/warpers_inl.hpp | 16 +++---- modules/stitching/src/matchers.cpp | 2 +- modules/stitching/src/motion_estimators.cpp | 2 +- modules/stitching/src/stitcher.cpp | 4 +- modules/ts/src/ts_perf.cpp | 10 ++--- samples/c/blobtrack_sample.cpp | 7 ++-- samples/c/mushroom.cpp | 2 +- samples/c/tree_engine.cpp | 2 +- ...Rimages_HighDynamicRange_Retina_toneMapping.cpp | 3 +- ...s_HighDynamicRange_Retina_toneMapping_video.cpp | 11 +++-- samples/cpp/bagofwords_classification.cpp | 30 ++++++------- samples/cpp/calibration.cpp | 2 +- samples/cpp/ffilldemo.cpp | 8 ++-- samples/cpp/hybridtrackingsample.cpp | 22 +++++----- samples/cpp/latentsvm_multidetect.cpp | 6 +-- samples/cpp/linemod.cpp | 49 ++++++++++++---------- samples/cpp/matching_to_many_images.cpp | 2 +- samples/cpp/openni_capture.cpp | 2 +- samples/cpp/peopledetect.cpp | 2 +- samples/cpp/phase_corr.cpp | 2 +- samples/cpp/point_cloud.cpp | 2 +- samples/cpp/points_classifier.cpp | 2 +- samples/cpp/rgbdodometry.cpp | 14 +++---- samples/cpp/select3dobj.cpp | 4 +- samples/cpp/stitching_detailed.cpp | 5 ++- samples/cpp/video_dmtx.cpp | 2 +- samples/gpu/alpha_comp.cpp | 2 +- samples/gpu/brox_optical_flow.cpp | 2 +- samples/gpu/performance/tests.cpp | 2 +- 83 files changed, 317 insertions(+), 306 deletions(-) diff --git a/apps/traincascade/HOGfeatures.h b/apps/traincascade/HOGfeatures.h index d6e1b58..56b269e 100644 --- a/apps/traincascade/HOGfeatures.h +++ b/apps/traincascade/HOGfeatures.h @@ -65,10 +65,10 @@ inline float CvHOGEvaluator::Feature::calc( const vector& _hists, const Mat int binIdx = featComponent % N_BINS; int cellIdx = featComponent / N_BINS; - const float *hist = _hists[binIdx].ptr(y); + const float *hist = _hists[binIdx].ptr((int)y); res = hist[fastRect[cellIdx].p0] - hist[fastRect[cellIdx].p1] - hist[fastRect[cellIdx].p2] + hist[fastRect[cellIdx].p3]; - const float *normSum = _normSum.ptr(y); + const float *normSum = _normSum.ptr((int)y); normFactor = (float)(normSum[fastRect[0].p0] - normSum[fastRect[1].p1] - normSum[fastRect[2].p2] + normSum[fastRect[3].p3]); res = (res > 0.001f) ? ( res / (normFactor + 0.001f) ) : 0.f; //for cutting negative values, which apper due to floating precision diff --git a/apps/traincascade/boost.cpp b/apps/traincascade/boost.cpp index e449fac..7aeab7f 100644 --- a/apps/traincascade/boost.cpp +++ b/apps/traincascade/boost.cpp @@ -275,7 +275,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id if( _subsample_idx ) { - CV_Assert( isubsample_idx = cvPreprocessIndexArray( _subsample_idx, sample_count ) ); + CV_Assert( (isubsample_idx = cvPreprocessIndexArray( _subsample_idx, sample_count )) != 0 ); if( isubsample_idx->cols + isubsample_idx->rows - 1 == sample_count ) { @@ -321,7 +321,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id root = new_node( 0, count, 1, 0 ); - CV_Assert( subsample_co = cvCreateMat( 1, sample_count*2, CV_32SC1 )); + CV_Assert( (subsample_co = cvCreateMat( 1, sample_count*2, CV_32SC1 )) != 0); cvZero( subsample_co ); co = subsample_co->data.i; for( int i = 0; i < count; i++ ) diff --git a/modules/calib3d/perf/perf_pnp.cpp b/modules/calib3d/perf/perf_pnp.cpp index 24bfe73..315022d 100644 --- a/modules/calib3d/perf/perf_pnp.cpp +++ b/modules/calib3d/perf/perf_pnp.cpp @@ -40,7 +40,7 @@ PERF_TEST_P(PointsNum_Algo, solvePnP, projectPoints(points3d, rvec, tvec, intrinsics, distortion, points2d); //add noise - Mat noise(1, points2d.size(), CV_32FC2); + Mat noise(1, (int)points2d.size(), CV_32FC2); randu(noise, 0, 0.01); add(points2d, noise, points2d); @@ -75,7 +75,7 @@ PERF_TEST(PointsNum_Algo, solveP3P) projectPoints(points3d, rvec, tvec, intrinsics, distortion, points2d); //add noise - Mat noise(1, points2d.size(), CV_32FC2); + Mat noise(1, (int)points2d.size(), CV_32FC2); randu(noise, 0, 0.01); add(points2d, noise, points2d); diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index 5b99b36..9d0f621 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -92,10 +92,7 @@ bool cv::solvePnP( InputArray _opoints, InputArray _ipoints, return true; } else - { CV_Error(CV_StsBadArg, "The flags argument must be one of CV_ITERATIVE or CV_EPNP"); - return false; - } return false; } diff --git a/modules/calib3d/test/test_homography.cpp b/modules/calib3d/test/test_homography.cpp index 0c4a4e1..a424782 100644 --- a/modules/calib3d/test/test_homography.cpp +++ b/modules/calib3d/test/test_homography.cpp @@ -64,8 +64,8 @@ #define COUNT_NORM_TYPES 3 #define METHODS_COUNT 3 -size_t NORM_TYPE[COUNT_NORM_TYPES] = {cv::NORM_L1, cv::NORM_L2, cv::NORM_INF}; -size_t METHOD[METHODS_COUNT] = {0, CV_RANSAC, CV_LMEDS}; +int NORM_TYPE[COUNT_NORM_TYPES] = {cv::NORM_L1, cv::NORM_L2, cv::NORM_INF}; +int METHOD[METHODS_COUNT] = {0, CV_RANSAC, CV_LMEDS}; using namespace cv; using namespace std; @@ -247,13 +247,13 @@ void CV_HomographyTest::print_information_8(int j, int N, int k, int l, double d void CV_HomographyTest::run(int) { - for (size_t N = 4; N <= MAX_COUNT_OF_POINTS; ++N) + for (int N = 4; N <= MAX_COUNT_OF_POINTS; ++N) { RNG& rng = ts->get_rng(); float *src_data = new float [2*N]; - for (size_t i = 0; i < N; ++i) + for (int i = 0; i < N; ++i) { src_data[2*i] = (float)cvtest::randReal(rng)*image_size; src_data[2*i+1] = (float)cvtest::randReal(rng)*image_size; @@ -266,7 +266,7 @@ void CV_HomographyTest::run(int) vector src_vec, dst_vec; - for (size_t i = 0; i < N; ++i) + for (int i = 0; i < N; ++i) { float *tmp = src_mat_2d.ptr()+2*i; src_mat_3d.at(0, i) = tmp[0]; @@ -293,7 +293,7 @@ void CV_HomographyTest::run(int) dst_mat_2d.create(2, N, CV_32F); dst_mat_2f.create(1, N, CV_32FC2); - for (size_t i = 0; i < N; ++i) + for (int i = 0; i < N; ++i) { float *tmp_2f = dst_mat_2f.ptr()+2*i; tmp_2f[0] = dst_mat_2d.at(0, i) = dst_mat_3d.at(0, i) /= dst_mat_3d.at(2, i); @@ -303,7 +303,7 @@ void CV_HomographyTest::run(int) dst_vec.push_back(Point2f(tmp_2f[0], tmp_2f[1])); } - for (size_t i = 0; i < METHODS_COUNT; ++i) + for (int i = 0; i < METHODS_COUNT; ++i) { method = METHOD[i]; switch (method) @@ -316,7 +316,7 @@ void CV_HomographyTest::run(int) cv::findHomography(src_vec, dst_mat_2f, method), cv::findHomography(src_vec, dst_vec, method) }; - for (size_t j = 0; j < 4; ++j) + for (int j = 0; j < 4; ++j) { if (!check_matrix_size(H_res_64[j])) @@ -328,7 +328,7 @@ void CV_HomographyTest::run(int) double diff; - for (size_t k = 0; k < COUNT_NORM_TYPES; ++k) + for (int k = 0; k < COUNT_NORM_TYPES; ++k) if (!check_matrix_diff(H_64, H_res_64[j], NORM_TYPE[k], diff)) { print_information_2(j, N, method, H_64, H_res_64[j], k, diff); @@ -348,7 +348,7 @@ void CV_HomographyTest::run(int) cv::findHomography(src_vec, dst_mat_2f, CV_RANSAC, reproj_threshold, mask[2]), cv::findHomography(src_vec, dst_vec, CV_RANSAC, reproj_threshold, mask[3]) }; - for (size_t j = 0; j < 4; ++j) + for (int j = 0; j < 4; ++j) { if (!check_matrix_size(H_res_64[j])) @@ -358,7 +358,7 @@ void CV_HomographyTest::run(int) return; } - for (size_t k = 0; k < COUNT_NORM_TYPES; ++k) + for (int k = 0; k < COUNT_NORM_TYPES; ++k) if (!check_matrix_diff(H_64, H_res_64[j], NORM_TYPE[k], diff)) { print_information_2(j, N, method, H_64, H_res_64[j], k, diff); @@ -398,14 +398,14 @@ void CV_HomographyTest::run(int) cv::Mat mask(N, 1, CV_8UC1); - for (size_t i = 0; i < N; ++i) + for (int i = 0; i < N; ++i) { float *a = noise_2f.ptr()+2*i, *_2f = dst_mat_2f.ptr()+2*i; _2f[0] += a[0]; _2f[1] += a[1]; mask.at(i, 0) = !(sqrt(a[0]*a[0]+a[1]*a[1]) > reproj_threshold); } - for (size_t i = 0; i < METHODS_COUNT; ++i) + for (int i = 0; i < METHODS_COUNT; ++i) { method = METHOD[i]; switch (method) @@ -418,7 +418,7 @@ void CV_HomographyTest::run(int) cv::findHomography(src_vec, dst_mat_2f), cv::findHomography(src_vec, dst_vec) }; - for (size_t j = 0; j < 4; ++j) + for (int j = 0; j < 4; ++j) { if (!check_matrix_size(H_res_64[j])) @@ -432,7 +432,7 @@ void CV_HomographyTest::run(int) cv::Mat dst_res_3d(3, N, CV_32F), noise_2d(2, N, CV_32F); - for (size_t k = 0; k < N; ++k) + for (int k = 0; k < N; ++k) { Mat tmp_mat_3d = H_res_32*src_mat_3d.col(k); @@ -444,7 +444,7 @@ void CV_HomographyTest::run(int) float *a = noise_2f.ptr()+2*k; noise_2d.at(0, k) = a[0]; noise_2d.at(1, k) = a[1]; - for (size_t l = 0; l < COUNT_NORM_TYPES; ++l) + for (int l = 0; l < COUNT_NORM_TYPES; ++l) if (cv::norm(tmp_mat_3d, dst_mat_3d.col(k), NORM_TYPE[l]) - cv::norm(noise_2d.col(k), NORM_TYPE[l]) > max_2diff) { print_information_4(method, j, N, k, l, cv::norm(tmp_mat_3d, dst_mat_3d.col(k), NORM_TYPE[l]) - cv::norm(noise_2d.col(k), NORM_TYPE[l])); @@ -454,7 +454,7 @@ void CV_HomographyTest::run(int) } - for (size_t l = 0; l < COUNT_NORM_TYPES; ++l) + for (int l = 0; l < COUNT_NORM_TYPES; ++l) if (cv::norm(dst_res_3d, dst_mat_3d, NORM_TYPE[l]) - cv::norm(noise_2d, NORM_TYPE[l]) > max_diff) { print_information_5(method, j, N, l, cv::norm(dst_res_3d, dst_mat_3d, NORM_TYPE[l]) - cv::norm(noise_2d, NORM_TYPE[l])); @@ -475,9 +475,8 @@ void CV_HomographyTest::run(int) cv::findHomography(src_vec, dst_mat_2f, CV_RANSAC, reproj_threshold, mask_res[2]), cv::findHomography(src_vec, dst_vec, CV_RANSAC, reproj_threshold, mask_res[3]) }; - for (size_t j = 0; j < 4; ++j) + for (int j = 0; j < 4; ++j) { - if (!check_matrix_size(H_res_64[j])) { print_information_1(j, N, method, H_res_64[j]); @@ -506,7 +505,7 @@ void CV_HomographyTest::run(int) cv::Mat dst_res_3d = H_res_32*src_mat_3d; - for (size_t k = 0; k < N; ++k) + for (int k = 0; k < N; ++k) { dst_res_3d.at(0, k) /= dst_res_3d.at(2, k); dst_res_3d.at(1, k) /= dst_res_3d.at(2, k); @@ -542,7 +541,7 @@ void CV_HomographyTest::run(int) cv::Mat noise_2d(2, 1, CV_32F); noise_2d.at(0, 0) = a[0]; noise_2d.at(1, 0) = a[1]; - for (size_t l = 0; l < COUNT_NORM_TYPES; ++l) + for (int l = 0; l < COUNT_NORM_TYPES; ++l) { diff = cv::norm(dst_res_3d.col(k), dst_mat_3d.col(k), NORM_TYPE[l]); diff --git a/modules/calib3d/test/test_solvepnp_ransac.cpp b/modules/calib3d/test/test_solvepnp_ransac.cpp index e4e3989..6683fbc 100644 --- a/modules/calib3d/test/test_solvepnp_ransac.cpp +++ b/modules/calib3d/test/test_solvepnp_ransac.cpp @@ -126,7 +126,7 @@ protected: { if (i % 20 == 0) { - projectedPoints[i] = projectedPoints[rng.uniform(0,points.size()-1)]; + projectedPoints[i] = projectedPoints[rng.uniform(0,(int)points.size()-1)]; } } diff --git a/modules/contrib/include/opencv2/contrib/contrib.hpp b/modules/contrib/include/opencv2/contrib/contrib.hpp index 93c0c51..eaab0a0 100644 --- a/modules/contrib/include/opencv2/contrib/contrib.hpp +++ b/modules/contrib/include/opencv2/contrib/contrib.hpp @@ -629,19 +629,16 @@ namespace cv * Estimate the rigid body motion from frame0 to frame1. The method is based on the paper * "Real-Time Visual Odometry from Dense RGB-D Images", F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011. */ - CV_EXPORTS struct TransformationType - { - enum { ROTATION = 1, - TRANSLATION = 2, - RIGID_BODY_MOTION = 4 - }; - }; + enum { ROTATION = 1, + TRANSLATION = 2, + RIGID_BODY_MOTION = 4 + }; CV_EXPORTS bool RGBDOdometry( cv::Mat& Rt, const Mat& initRt, const cv::Mat& image0, const cv::Mat& depth0, const cv::Mat& mask0, const cv::Mat& image1, const cv::Mat& depth1, const cv::Mat& mask1, const cv::Mat& cameraMatrix, float minDepth, float maxDepth, float maxDepthDiff, const std::vector& iterCounts, const std::vector& minGradientMagnitudes, - int transformType=TransformationType::RIGID_BODY_MOTION ); + int transformType=RIGID_BODY_MOTION ); } #include "opencv2/contrib/retina.hpp" diff --git a/modules/contrib/src/gencolors.cpp b/modules/contrib/src/gencolors.cpp index 1774631..12ef9d9 100644 --- a/modules/contrib/src/gencolors.cpp +++ b/modules/contrib/src/gencolors.cpp @@ -53,9 +53,9 @@ void downsamplePoints( const Mat& src, Mat& dst, size_t count ) CV_Assert( src.total() >= count ); CV_Assert( src.type() == CV_8UC3); - dst.create( 1, count, CV_8UC3 ); + dst.create( 1, (int)count, CV_8UC3 ); //TODO: optimize by exploiting symmetry in the distance matrix - Mat dists( src.total(), src.total(), CV_32FC1, Scalar(0) ); + Mat dists( (int)src.total(), (int)src.total(), CV_32FC1, Scalar(0) ); if( dists.empty() ) std::cerr << "Such big matrix cann't be created." << std::endl; @@ -88,7 +88,7 @@ void downsamplePoints( const Mat& src, Mat& dst, size_t count ) Mat minDists; reduce( activedDists, minDists, 0, CV_REDUCE_MIN ); minMaxLoc( minDists, 0, &maxVal, 0, &maxLoc, candidatePointsMask ); - dst.at >(i) = src.at >(maxLoc.x); + dst.at >((int)i) = src.at >(maxLoc.x); } } @@ -113,7 +113,7 @@ void cv::generateColors( std::vector& colors, size_t count, size_t facto // Generate a set of colors in RGB space. A size of the set is severel times (=factor) larger then // the needed count of colors. - Mat bgr( 1, count*factor, CV_8UC3 ); + Mat bgr( 1, (int)(count*factor), CV_8UC3 ); randu( bgr, 0, 256 ); // Convert the colors set to Lab space. @@ -134,7 +134,7 @@ void cv::generateColors( std::vector& colors, size_t count, size_t facto CV_Assert( bgr_subset.total() == count ); for( size_t i = 0; i < count; i++ ) { - Point3_ c = bgr_subset.at >(i); + Point3_ c = bgr_subset.at >((int)i); colors[i] = Scalar(c.x, c.y, c.z); } } diff --git a/modules/contrib/src/rgbdodometry.cpp b/modules/contrib/src/rgbdodometry.cpp index 907171d..43eab09 100644 --- a/modules/contrib/src/rgbdodometry.cpp +++ b/modules/contrib/src/rgbdodometry.cpp @@ -148,8 +148,8 @@ void cvtDepth2Cloud( const Mat& depth, Mat& cloud, const Mat& cameraMatrix ) for( int x = 0; x < cloud.cols; x++ ) { float z = depth_prt[x]; - cloud_ptr[x].x = (x - ox) * z * inv_fx; - cloud_ptr[x].y = (y - oy) * z * inv_fy; + cloud_ptr[x].x = (float)((x - ox) * z * inv_fx); + cloud_ptr[x].y = (float)((y - oy) * z * inv_fy); cloud_ptr[x].z = z; } } @@ -242,7 +242,7 @@ int computeCorresp( const Mat& K, const Mat& K_inv, const Mat& Rt, float d1 = depth1.at(v1,u1); if( !cvIsNaN(d1) && texturedMask1.at(v1,u1) ) { - float transformed_d1 = d1 * (KRK_inv_ptr[6] * u1 + KRK_inv_ptr[7] * v1 + KRK_inv_ptr[8]) + Kt_ptr[2]; + float transformed_d1 = (float)(d1 * (KRK_inv_ptr[6] * u1 + KRK_inv_ptr[7] * v1 + KRK_inv_ptr[8]) + Kt_ptr[2]); int u0 = cvRound((d1 * (KRK_inv_ptr[0] * u1 + KRK_inv_ptr[1] * v1 + KRK_inv_ptr[2]) + Kt_ptr[0]) / transformed_d1); int v0 = cvRound((d1 * (KRK_inv_ptr[3] * u1 + KRK_inv_ptr[4] * v1 + KRK_inv_ptr[5]) + Kt_ptr[1]) / transformed_d1); @@ -257,7 +257,7 @@ int computeCorresp( const Mat& K, const Mat& K_inv, const Mat& Rt, int exist_u1, exist_v1; get2shorts( c, exist_u1, exist_v1); - float exist_d1 = depth1.at(exist_v1,exist_u1) * (KRK_inv_ptr[6] * exist_u1 + KRK_inv_ptr[7] * exist_v1 + KRK_inv_ptr[8]) + Kt_ptr[2]; + float exist_d1 = (float)(depth1.at(exist_v1,exist_u1) * (KRK_inv_ptr[6] * exist_u1 + KRK_inv_ptr[7] * exist_v1 + KRK_inv_ptr[8]) + Kt_ptr[2]); if( transformed_d1 > exist_d1 ) continue; @@ -307,7 +307,7 @@ void buildPyramids( const Mat& image0, const Mat& image1, vector& pyramid_dI_dx1, vector& pyramid_dI_dy1, vector& pyramidTexturedMask1, vector& pyramidCameraMatrix ) { - const int pyramidMaxLevel = minGradMagnitudes.size() - 1; + const int pyramidMaxLevel = (int)minGradMagnitudes.size() - 1; buildPyramid( image0, pyramidImage0, pyramidMaxLevel ); buildPyramid( image1, pyramidImage1, pyramidMaxLevel ); @@ -330,12 +330,12 @@ void buildPyramids( const Mat& image0, const Mat& image1, const Mat& dy = pyramid_dI_dy1[i]; Mat texturedMask( dx.size(), CV_8UC1, Scalar(0) ); - const float minScalesGradMagnitude2 = (minGradMagnitudes[i] * minGradMagnitudes[i]) / (sobelScale * sobelScale); + const float minScalesGradMagnitude2 = (float)((minGradMagnitudes[i] * minGradMagnitudes[i]) / (sobelScale * sobelScale)); for( int y = 0; y < dx.rows; y++ ) { for( int x = 0; x < dx.cols; x++ ) { - float m2 = dx.at(y,x)*dx.at(y,x) + dy.at(y,x)*dy.at(y,x); + float m2 = (float)(dx.at(y,x)*dx.at(y,x) + dy.at(y,x)*dy.at(y,x)); if( m2 >= minScalesGradMagnitude2 ) texturedMask.at(y,x) = 255; } @@ -398,17 +398,17 @@ bool computeKsi( int transformType, { int Cwidth = -1; ComputeCFuncPtr computeCFuncPtr = 0; - if( transformType == TransformationType::RIGID_BODY_MOTION ) + if( transformType == RIGID_BODY_MOTION ) { Cwidth = 6; computeCFuncPtr = computeC_RigidBodyMotion; } - else if( transformType == TransformationType::ROTATION ) + else if( transformType == ROTATION ) { Cwidth = 3; computeCFuncPtr = computeC_Rotation; } - else if( transformType == TransformationType::TRANSLATION ) + else if( transformType == TRANSLATION ) { Cwidth = 3; computeCFuncPtr = computeC_Translation; @@ -450,15 +450,15 @@ bool computeKsi( int transformType, ksi = Scalar(0); Mat subksi; - if( transformType == TransformationType::RIGID_BODY_MOTION ) + if( transformType == RIGID_BODY_MOTION ) { subksi = ksi; } - else if( transformType == TransformationType::ROTATION ) + else if( transformType == ROTATION ) { subksi = ksi.rowRange(0,3); } - else if( transformType == TransformationType::TRANSLATION ) + else if( transformType == TRANSLATION ) { subksi = ksi.rowRange(3,6); } @@ -514,7 +514,7 @@ bool cv::RGBDOdometry( cv::Mat& Rt, const Mat& initRt, Mat resultRt = initRt.empty() ? Mat::eye(4,4,CV_64FC1) : initRt.clone(); Mat currRt, ksi; - for( int level = iterCounts.size() - 1; level >= 0; level-- ) + for( int level = (int)iterCounts.size() - 1; level >= 0; level-- ) { const Mat& levelCameraMatrix = pyramidCameraMatrix[level]; diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index 05d8c72..6806821 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -940,11 +940,11 @@ CVAPI(void*) cvMemStorageAlloc( CvMemStorage* storage, size_t size ); /* Allocates string in memory storage */ CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, - int len CV_DEFAULT(-1) ); + int len CV_DEFAULT(-1) ); /* Creates new empty sequence that will reside in the specified storage */ -CVAPI(CvSeq*) cvCreateSeq( int seq_flags, int header_size, - int elem_size, CvMemStorage* storage ); +CVAPI(CvSeq*) cvCreateSeq( int seq_flags, size_t header_size, + size_t elem_size, CvMemStorage* storage ); /* Changes default size (granularity) of sequence blocks. The default size is ~1Kbyte */ diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 5df670c..e493bfa 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -862,9 +862,9 @@ template struct CV_EXPORTS Matx_FastSolveOp<_Tp, 2, 1> template struct CV_EXPORTS Matx_FastSolveOp<_Tp, 3, 1> { bool operator()(const Matx<_Tp, 3, 3>& a, const Matx<_Tp, 3, 1>& b, - Matx<_Tp, 3, 1>& x, int method) const + Matx<_Tp, 3, 1>& x, int) const { - _Tp d = determinant(a); + _Tp d = (_Tp)determinant(a); if( d == 0 ) return false; d = 1/d; @@ -955,7 +955,7 @@ _AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n) { _AccTp s = 0; int i= 0; - #if CV_ENABLE_UNROLLED +#if CV_ENABLE_UNROLLED for(; i <= n - 4; i += 4 ) { _AccTp v0 = a[i] - b[i], v1 = a[i+1] - b[i+1], v2 = a[i+2] - b[i+2], v3 = a[i+3] - b[i+3]; @@ -964,7 +964,7 @@ _AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n) #endif for( ; i < n; i++ ) { - _AccTp v = a[i] - b[i]; + _AccTp v = (_AccTp)(a[i] - b[i]); s += v*v; } return s; @@ -995,7 +995,7 @@ _AccTp normL1(const _Tp* a, const _Tp* b, int n) { _AccTp s = 0; int i= 0; - #if CV_ENABLE_UNROLLED +#if CV_ENABLE_UNROLLED for(; i <= n - 4; i += 4 ) { _AccTp v0 = a[i] - b[i], v1 = a[i+1] - b[i+1], v2 = a[i+2] - b[i+2], v3 = a[i+3] - b[i+3]; @@ -1004,7 +1004,7 @@ _AccTp normL1(const _Tp* a, const _Tp* b, int n) #endif for( ; i < n; i++ ) { - _AccTp v = a[i] - b[i]; + _AccTp v = (_AccTp)(a[i] - b[i]); s += std::abs(v); } return s; diff --git a/modules/core/perf/perf_math.cpp b/modules/core/perf/perf_math.cpp index b7dab14..de97210 100644 --- a/modules/core/perf/perf_math.cpp +++ b/modules/core/perf/perf_math.cpp @@ -10,7 +10,7 @@ typedef perf::TestBaseWithParam VectorLength; PERF_TEST_P(VectorLength, phase32f, testing::Values(128, 1000, 128*1024, 512*1024, 1024*1024)) { - int length = GetParam(); + size_t length = GetParam(); vector X(length); vector Y(length); vector angle(length); diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index d1a4ab5..01e1f4f 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -2073,8 +2073,8 @@ static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t ste int x =0; #if CV_SSE2 if( USE_SSE2 ){ - __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi8 (0xff); - __m128i c128 = _mm_set1_epi8 (128); + __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi8 (-1); + __m128i c128 = _mm_set1_epi8 (-128); for( ; x <= size.width - 16; x += 16 ) { __m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x)); @@ -2103,7 +2103,7 @@ static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t ste int x = 0; #if CV_SSE2 if( USE_SSE2 ){ - __m128i m128 = code == CMP_EQ ? _mm_setzero_si128() : _mm_set1_epi8 (0xff); + __m128i m128 = code == CMP_EQ ? _mm_setzero_si128() : _mm_set1_epi8 (-1); for( ; x <= size.width - 16; x += 16 ) { __m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x)); @@ -2154,7 +2154,7 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st int x =0; #if CV_SSE2 if( USE_SSE2){// - __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi16 (0xffff); + __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi16 (-1); for( ; x <= size.width - 16; x += 16 ) { __m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x)); @@ -2192,7 +2192,7 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st int x = 0; #if CV_SSE2 if( USE_SSE2 ){ - __m128i m128 = code == CMP_EQ ? _mm_setzero_si128() : _mm_set1_epi16 (0xffff); + __m128i m128 = code == CMP_EQ ? _mm_setzero_si128() : _mm_set1_epi16 (-1); for( ; x <= size.width - 16; x += 16 ) { __m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x)); diff --git a/modules/core/src/cmdparser.cpp b/modules/core/src/cmdparser.cpp index c76cf4e..cc173ec 100644 --- a/modules/core/src/cmdparser.cpp +++ b/modules/core/src/cmdparser.cpp @@ -294,15 +294,15 @@ template for(;;) { bool tr = ((int)buf.length() > col_d-2) ? true: false; - int pos; + std::string::size_type pos = 0; if (tr) { pos = buf.find_first_of(' '); for(;;) { - if ((int)buf.find_first_of(' ', pos + 1 ) < col_d-2 && - (int)buf.find_first_of(' ', pos + 1 ) != (int)std::string::npos) + if (buf.find_first_of(' ', pos + 1 ) < (std::string::size_type)(col_d-2) && + buf.find_first_of(' ', pos + 1 ) != std::string::npos) pos = buf.find_first_of(' ', pos + 1); else break; diff --git a/modules/core/src/datastructs.cpp b/modules/core/src/datastructs.cpp index 59a4829..0860d8d 100644 --- a/modules/core/src/datastructs.cpp +++ b/modules/core/src/datastructs.cpp @@ -362,35 +362,35 @@ cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, int len ) /* Create empty sequence: */ CV_IMPL CvSeq * -cvCreateSeq( int seq_flags, int header_size, int elem_size, CvMemStorage * storage ) +cvCreateSeq( int seq_flags, size_t header_size, size_t elem_size, CvMemStorage* storage ) { CvSeq *seq = 0; if( !storage ) CV_Error( CV_StsNullPtr, "" ); - if( header_size < (int)sizeof( CvSeq ) || elem_size <= 0 ) + if( header_size < sizeof( CvSeq ) || elem_size <= 0 ) CV_Error( CV_StsBadSize, "" ); /* allocate sequence header */ seq = (CvSeq*)cvMemStorageAlloc( storage, header_size ); memset( seq, 0, header_size ); - seq->header_size = header_size; + seq->header_size = (int)header_size; seq->flags = (seq_flags & ~CV_MAGIC_MASK) | CV_SEQ_MAGIC_VAL; { int elemtype = CV_MAT_TYPE(seq_flags); int typesize = CV_ELEM_SIZE(elemtype); if( elemtype != CV_SEQ_ELTYPE_GENERIC && elemtype != CV_USRTYPE1 && - typesize != 0 && typesize != elem_size ) + typesize != 0 && typesize != (int)elem_size ) CV_Error( CV_StsBadSize, "Specified element size doesn't match to the size of the specified element type " "(try to use 0 for element type)" ); } - seq->elem_size = elem_size; + seq->elem_size = (int)elem_size; seq->storage = storage; - cvSetSeqBlockSize( seq, (1 << 10)/elem_size ); + cvSetSeqBlockSize( seq, (int)((1 << 10)/elem_size) ); return seq; } diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 6057f65..0746aaf 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -853,6 +853,7 @@ icvProcessSpecialDouble( CvFileStorage* fs, char* buf, double* value, char** end CV_PARSE_ERROR( "Bad format of floating-point constant" ); union{double d; uint64 i;} v; + v.d = 0.; if( toupper(buf[1]) == 'I' && toupper(buf[2]) == 'N' && toupper(buf[3]) == 'F' ) v.i = (uint64)inf_hi << 32; else if( toupper(buf[1]) == 'N' && toupper(buf[2]) == 'A' && toupper(buf[3]) == 'N' ) diff --git a/modules/core/test/test_countnonzero.cpp b/modules/core/test/test_countnonzero.cpp index 7d0f2bb..2aae11f 100644 --- a/modules/core/test/test_countnonzero.cpp +++ b/modules/core/test/test_countnonzero.cpp @@ -112,7 +112,7 @@ void CV_CountNonZeroTest::generate_src_data(cv::Size size, int type, int count_n while (n < count_non_zero) { - size_t i = rng.next()%size.height, j = rng.next()%size.width; + int i = rng.next()%size.height, j = rng.next()%size.width; switch (type) { @@ -151,20 +151,15 @@ int CV_CountNonZeroTest::get_count_non_zero() for (int i = 0; i < src.rows; ++i) for (int j = 0; j < src.cols; ++j) - + { if (current_type == CV_8U) result += (src.at(i, j) > 0); - - else if (current_type == CV_8S) result += abs(sign(src.at(i, j))); - - else if (current_type == CV_16U) result += (src.at(i, j) > 0); - - else if (current_type == CV_16S) result += abs(sign(src.at(i, j))); - - else if (current_type == CV_32S) result += abs(sign(src.at(i, j))); - - else if (current_type == CV_32F) result += (fabs(src.at(i, j)) > eps_32); - - else result += (fabs(src.at(i, j)) > eps_64); + else if (current_type == CV_8S) result += abs(sign(src.at(i, j))); + else if (current_type == CV_16U) result += (src.at(i, j) > 0); + else if (current_type == CV_16S) result += abs(sign(src.at(i, j))); + else if (current_type == CV_32S) result += abs(sign(src.at(i, j))); + else if (current_type == CV_32F) result += (fabs(src.at(i, j)) > eps_32); + else result += (fabs(src.at(i, j)) > eps_64); + } return result; } diff --git a/modules/core/test/test_eigen.cpp b/modules/core/test/test_eigen.cpp index 200a727..b05857e 100644 --- a/modules/core/test/test_eigen.cpp +++ b/modules/core/test/test_eigen.cpp @@ -61,8 +61,8 @@ using namespace std; #define MESSAGE_ERROR_ORTHO "Matrix of eigen vectors is not orthogonal." #define MESSAGE_ERROR_ORDER "Eigen values are not sorted in ascending order." -const size_t COUNT_NORM_TYPES = 3; -const size_t NORM_TYPE[COUNT_NORM_TYPES] = {cv::NORM_L1, cv::NORM_L2, cv::NORM_INF}; +const int COUNT_NORM_TYPES = 3; +const int NORM_TYPE[COUNT_NORM_TYPES] = {cv::NORM_L1, cv::NORM_L2, cv::NORM_INF}; enum TASK_TYPE_EIGEN {VALUES, VECTORS}; @@ -232,7 +232,7 @@ bool Core_EigenTest::check_orthogonality(const cv::Mat& U) cv::Mat E = Mat::eye(U.rows, U.cols, type); - for (size_t i = 0; i < COUNT_NORM_TYPES; ++i) + for (int i = 0; i < COUNT_NORM_TYPES; ++i) { double diff = cv::norm(UUt, E, NORM_TYPE[i]); if (diff > eps_vec) @@ -253,7 +253,7 @@ bool Core_EigenTest::check_pairs_order(const cv::Mat& eigen_values) { case CV_32FC1: { - for (size_t i = 0; i < eigen_values.total() - 1; ++i) + for (int i = 0; i < (int)(eigen_values.total() - 1); ++i) if (!(eigen_values.at(i, 0) > eigen_values.at(i+1, 0))) { std::cout << endl; std::cout << "Checking order of eigen values vector " << eigen_values << "..." << endl; @@ -268,7 +268,7 @@ bool Core_EigenTest::check_pairs_order(const cv::Mat& eigen_values) case CV_64FC1: { - for (size_t i = 0; i < eigen_values.total() - 1; ++i) + for (int i = 0; i < (int)(eigen_values.total() - 1); ++i) if (!(eigen_values.at(i, 0) > eigen_values.at(i+1, 0))) { std::cout << endl; std::cout << "Checking order of eigen values vector " << eigen_values << "..." << endl; @@ -338,7 +338,7 @@ bool Core_EigenTest::test_pairs(const cv::Mat& src) cv::Mat disparity = src_evec - eval_evec; - for (size_t i = 0; i < COUNT_NORM_TYPES; ++i) + for (int i = 0; i < COUNT_NORM_TYPES; ++i) { double diff = cv::norm(disparity, NORM_TYPE[i]); if (diff > eps_vec) @@ -367,7 +367,7 @@ bool Core_EigenTest::test_values(const cv::Mat& src) if (!check_pair_count(src, eigen_values_2)) return false; - for (size_t i = 0; i < COUNT_NORM_TYPES; ++i) + for (int i = 0; i < COUNT_NORM_TYPES; ++i) { double diff = cv::norm(eigen_values_1, eigen_values_2, NORM_TYPE[i]); if (diff > eps_val) @@ -391,7 +391,7 @@ bool Core_EigenTest::check_full(int type) for (int i = 1; i <= MATRIX_COUNT; ++i) { - size_t src_size = (int)(std::pow(2.0, (rand()%MAX_DEGREE+1)*1.0)); + int src_size = (int)(std::pow(2.0, (rand()%MAX_DEGREE+1)*1.0)); cv::Mat src(src_size, src_size, type); diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index fb8f0b1..829a6cf 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -191,7 +191,7 @@ void FAST(InputArray _img, std::vector& keypoints, int threshold, bool Mat img = _img.getMat(); const int K = 8, N = 16 + K + 1; int i, j, k, pixel[N]; - makeOffsets(pixel, img.step); + makeOffsets(pixel, (int)img.step); for(k = 16; k < N; k++) pixel[k] = pixel[k - 16]; @@ -200,7 +200,7 @@ void FAST(InputArray _img, std::vector& keypoints, int threshold, bool threshold = std::min(std::max(threshold, 0), 255); #if CV_SSE2 - __m128i delta = _mm_set1_epi8(128), t = _mm_set1_epi8(threshold), K16 = _mm_set1_epi8(K); + __m128i delta = _mm_set1_epi8(-128), t = _mm_set1_epi8((char)threshold), K16 = _mm_set1_epi8((char)K); #endif uchar threshold_tab[512]; for( i = -255; i <= 255; i++ ) @@ -279,7 +279,7 @@ void FAST(InputArray _img, std::vector& keypoints, int threshold, bool { cornerpos[ncorners++] = j+k; if(nonmax_suppression) - curr[j+k] = cornerScore(ptr+k, pixel, threshold); + curr[j+k] = (uchar)cornerScore(ptr+k, pixel, threshold); } } #endif @@ -317,7 +317,7 @@ void FAST(InputArray _img, std::vector& keypoints, int threshold, bool { cornerpos[ncorners++] = j; if(nonmax_suppression) - curr[j] = cornerScore(ptr, pixel, threshold); + curr[j] = (uchar)cornerScore(ptr, pixel, threshold); break; } } @@ -339,7 +339,7 @@ void FAST(InputArray _img, std::vector& keypoints, int threshold, bool { cornerpos[ncorners++] = j; if(nonmax_suppression) - curr[j] = cornerScore(ptr, pixel, threshold); + curr[j] = (uchar)cornerScore(ptr, pixel, threshold); break; } } diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index 3fd0239..b15dd64 100755 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -536,7 +536,7 @@ void FlannBasedMatcher::read( const FileNode& fn) FileNode ip = fn["indexParams"]; CV_Assert(ip.type() == FileNode::SEQ); - for(size_t i = 0; i < ip.size(); ++i) + for(int i = 0; i < (int)ip.size(); ++i) { CV_Assert(ip[i].type() == FileNode::MAP); std::string name = (std::string)ip[i]["name"]; @@ -561,7 +561,7 @@ void FlannBasedMatcher::read( const FileNode& fn) indexParams->setString(name, (std::string) ip[i]["value"]); break; case CV_MAKETYPE(CV_USRTYPE1,2): - indexParams->setBool(name, (int) ip[i]["value"]); + indexParams->setBool(name, (int) ip[i]["value"] != 0); break; case CV_MAKETYPE(CV_USRTYPE1,3): indexParams->setAlgorithm((int) ip[i]["value"]); @@ -575,7 +575,7 @@ void FlannBasedMatcher::read( const FileNode& fn) FileNode sp = fn["searchParams"]; CV_Assert(sp.type() == FileNode::SEQ); - for(size_t i = 0; i < sp.size(); ++i) + for(int i = 0; i < (int)sp.size(); ++i) { CV_Assert(sp[i].type() == FileNode::MAP); std::string name = (std::string)sp[i]["name"]; @@ -600,7 +600,7 @@ void FlannBasedMatcher::read( const FileNode& fn) searchParams->setString(name, (std::string) ip[i]["value"]); break; case CV_MAKETYPE(CV_USRTYPE1,2): - searchParams->setBool(name, (int) ip[i]["value"]); + searchParams->setBool(name, (int) ip[i]["value"] != 0); break; case CV_MAKETYPE(CV_USRTYPE1,3): searchParams->setAlgorithm((int) ip[i]["value"]); diff --git a/modules/features2d/src/mser.cpp b/modules/features2d/src/mser.cpp index e96ccc5..a930c60 100644 --- a/modules/features2d/src/mser.cpp +++ b/modules/features2d/src/mser.cpp @@ -191,8 +191,8 @@ inline void _bitreset(unsigned long * a, unsigned long b) struct MSERParams { - MSERParams( int _delta, int _minArea, int _maxArea, float _maxVariation, - float _minDiversity, int _maxEvolution, double _areaThreshold, + MSERParams( int _delta, int _minArea, int _maxArea, double _maxVariation, + double _minDiversity, int _maxEvolution, double _areaThreshold, double _minMargin, int _edgeBlurSize ) : delta(_delta), minArea(_minArea), maxArea(_maxArea), maxVariation(_maxVariation), minDiversity(_minDiversity), maxEvolution(_maxEvolution), areaThreshold(_areaThreshold), @@ -201,8 +201,8 @@ struct MSERParams int delta; int minArea; int maxArea; - float maxVariation; - float minDiversity; + double maxVariation; + double minDiversity; int maxEvolution; double areaThreshold; double minMargin; diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index ae4f234..2219f9c 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -785,7 +785,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke vector imagePyramid(nlevels), maskPyramid(nlevels); for (int level = 0; level < nlevels; ++level) { - float scale = 1/getScale(level, firstLevel, scale); + float scale = 1/getScale(level, firstLevel, scaleFactor); Size sz(cvRound(image.cols*scale), cvRound(image.rows*scale)); Size wholeSize(sz.width + border*2, sz.height + border*2); Mat temp(wholeSize, image.type()), masktemp; @@ -810,10 +810,11 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector& _ke } else { - float sf = scaleFactor; - resize(imagePyramid[level-1], imagePyramid[level], sz, 1./sf, 1./sf, INTER_LINEAR); + resize(imagePyramid[level-1], imagePyramid[level], sz, + 1./scaleFactor, 1./scaleFactor, INTER_LINEAR); if (!mask.empty()) - resize(maskPyramid[level-1], maskPyramid[level], sz, 1./sf, 1./sf, INTER_LINEAR); + resize(maskPyramid[level-1], maskPyramid[level], sz, + 1./scaleFactor, 1./scaleFactor, INTER_LINEAR); copyMakeBorder(imagePyramid[level], temp, border, border, border, border, BORDER_REFLECT_101+BORDER_ISOLATED); } diff --git a/modules/features2d/src/stardetector.cpp b/modules/features2d/src/stardetector.cpp index e81741b..3f75899 100644 --- a/modules/features2d/src/stardetector.cpp +++ b/modules/features2d/src/stardetector.cpp @@ -57,7 +57,7 @@ computeIntegralImages( const Mat& matI, Mat& matS, Mat& matT, Mat& _FT ) const uchar* I = matI.ptr(); int *S = matS.ptr(), *T = matT.ptr(), *FT = _FT.ptr(); - int istep = matI.step, step = matS.step/sizeof(S[0]); + int istep = (int)matI.step, step = (int)(matS.step/sizeof(S[0])); for( x = 0; x <= cols; x++ ) S[x] = T[x] = FT[x] = 0; diff --git a/modules/flann/include/opencv2/flann/ground_truth.h b/modules/flann/include/opencv2/flann/ground_truth.h index 8f1c698..7208b52 100644 --- a/modules/flann/include/opencv2/flann/ground_truth.h +++ b/modules/flann/include/opencv2/flann/ground_truth.h @@ -57,12 +57,12 @@ void find_nearest(const Matrix& dataset, typenam DistanceType tmp = distance(dataset[i], query, dataset.cols); if (dcnt(); - computeClustering(root[i], indices[i], size_, branching_,0); + computeClustering(root[i], indices[i], (int)size_, branching_,0); } } @@ -419,7 +419,7 @@ public: int maxChecks = get_param(searchParams,"checks",32); // Priority queue storing intermediate branches in the best-bin-first search - Heap* heap = new Heap(size_); + Heap* heap = new Heap((int)size_); std::vector checked(size_,false); int checks = 0; @@ -487,7 +487,7 @@ private: { save_value(stream, *node); if (node->childs==NULL) { - int indices_offset = node->indices - indices[num]; + int indices_offset = (int)(node->indices - indices[num]); save_value(stream, indices_offset); } else { diff --git a/modules/flann/include/opencv2/flann/index_testing.h b/modules/flann/include/opencv2/flann/index_testing.h index c98a14b..c2a0b50 100644 --- a/modules/flann/include/opencv2/flann/index_testing.h +++ b/modules/flann/include/opencv2/flann/index_testing.h @@ -116,7 +116,7 @@ float search_with_ground_truth(NNIndex& index, const Matrix(inputData, testData[i], neighbors, matches[i], testData.cols, nn, distance); + distR += computeDistanceRaport(inputData, testData[i], neighbors, matches[i], (int)testData.cols, nn, distance); } t.stop(); } diff --git a/modules/flann/include/opencv2/flann/kdtree_single_index.h b/modules/flann/include/opencv2/flann/kdtree_single_index.h index 6b169e3..b680aee 100644 --- a/modules/flann/include/opencv2/flann/kdtree_single_index.h +++ b/modules/flann/include/opencv2/flann/kdtree_single_index.h @@ -95,7 +95,7 @@ public: // Create a permutable array of indices to the input vectors. vind_.resize(size_); for (size_t i = 0; i < size_; i++) { - vind_[i] = i; + vind_[i] = (int)i; } } @@ -116,7 +116,7 @@ public: void buildIndex() { computeBoundingBox(root_bbox_); - root_node_ = divideTree(0, size_, root_bbox_ ); // construct the tree + root_node_ = divideTree(0, (int)size_, root_bbox_ ); // construct the tree if (reorder_) { delete[] data_.data; @@ -197,7 +197,7 @@ public: */ int usedMemory() const { - return pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int); // pool memory and vind array memory + return (int)(pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int)); // pool memory and vind array memory } @@ -461,7 +461,7 @@ private: computeMinMax(ind, count, cutfeat, min_elem, max_elem); DistanceType spread = (DistanceType)(max_elem-min_elem); if (spread>max_spread) { - cutfeat = i; + cutfeat = (int)i; max_spread = spread; } } @@ -524,11 +524,11 @@ private: for (size_t i = 0; i < dim_; ++i) { if (vec[i] < root_bbox_[i].low) { - dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].low, i); + dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].low, (int)i); distsq += dists[i]; } if (vec[i] > root_bbox_[i].high) { - dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].high, i); + dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].high, (int)i); distsq += dists[i]; } } diff --git a/modules/flann/include/opencv2/flann/kmeans_index.h b/modules/flann/include/opencv2/flann/kmeans_index.h index 624c27a..cdfd146 100644 --- a/modules/flann/include/opencv2/flann/kmeans_index.h +++ b/modules/flann/include/opencv2/flann/kmeans_index.h @@ -775,7 +775,7 @@ private: for (int i=0; i(index_params_,"key_size",20); multi_probe_level_ = get_param(index_params_,"multi_probe_level",2); - feature_size_ = dataset_.cols; + feature_size_ = (unsigned)dataset_.cols; fill_xor_mask(0, key_size_, multi_probe_level_, xor_masks_); } @@ -168,7 +168,7 @@ public: */ int usedMemory() const { - return dataset_.rows * sizeof(int); + return (int)(dataset_.rows * sizeof(int)); } @@ -344,7 +344,7 @@ private: std::vector::const_iterator xor_mask_end = xor_masks_.end(); for (; xor_mask != xor_mask_end; ++xor_mask) { size_t sub_key = key ^ (*xor_mask); - const lsh::Bucket* bucket = table->getBucketFromKey(sub_key); + const lsh::Bucket* bucket = table->getBucketFromKey((lsh::BucketKey)sub_key); if (bucket == 0) continue; // Go over each descriptor index @@ -355,7 +355,7 @@ private: // Process the rest of the candidates for (; training_index < last_training_index; ++training_index) { // Compute the Hamming distance - hamming_distance = distance_(vec, dataset_[*training_index], dataset_.cols); + hamming_distance = distance_(vec, dataset_[*training_index], (int)dataset_.cols); result.addPoint(hamming_distance, *training_index); } } diff --git a/modules/flann/include/opencv2/flann/lsh_table.h b/modules/flann/include/opencv2/flann/lsh_table.h index a245160..4948d05 100644 --- a/modules/flann/include/opencv2/flann/lsh_table.h +++ b/modules/flann/include/opencv2/flann/lsh_table.h @@ -151,7 +151,7 @@ public: LshTable(unsigned int /*feature_size*/, unsigned int /*key_size*/) { std::cerr << "LSH is not implemented for that type" << std::endl; - throw; + assert(0); } /** Add a feature to the table @@ -161,7 +161,7 @@ public: void add(unsigned int value, const ElementType* feature) { // Add the value to the corresponding bucket - BucketKey key = getKey(feature); + BucketKey key = (lsh::BucketKey)getKey(feature); switch (speed_level_) { case kArray: @@ -232,7 +232,7 @@ public: size_t getKey(const ElementType* /*feature*/) const { std::cerr << "LSH is not implemented for that type" << std::endl; - throw; + assert(0); return 1; } @@ -414,7 +414,7 @@ inline LshStats LshTable::getStats() const if (!buckets_speed_.empty()) { for (BucketsSpeed::const_iterator pbucket = buckets_speed_.begin(); pbucket != buckets_speed_.end(); ++pbucket) { - stats.bucket_sizes_.push_back(pbucket->size()); + stats.bucket_sizes_.push_back((lsh::FeatureIndex)pbucket->size()); stats.bucket_size_mean_ += pbucket->size(); } stats.bucket_size_mean_ /= buckets_speed_.size(); @@ -422,7 +422,7 @@ inline LshStats LshTable::getStats() const } else { for (BucketsSpace::const_iterator x = buckets_space_.begin(); x != buckets_space_.end(); ++x) { - stats.bucket_sizes_.push_back(x->second.size()); + stats.bucket_sizes_.push_back((lsh::FeatureIndex)x->second.size()); stats.bucket_size_mean_ += x->second.size(); } stats.bucket_size_mean_ /= buckets_space_.size(); diff --git a/modules/flann/include/opencv2/flann/nn_index.h b/modules/flann/include/opencv2/flann/nn_index.h index 6aed20e..d14e83a 100644 --- a/modules/flann/include/opencv2/flann/nn_index.h +++ b/modules/flann/include/opencv2/flann/nn_index.h @@ -114,7 +114,7 @@ public: int* indices_ptr = NULL; DistanceType* dists_ptr = NULL; if (indices.cols > 0) { - n = indices.cols; + n = (int)indices.cols; indices_ptr = indices[0]; dists_ptr = dists[0]; } @@ -127,7 +127,7 @@ public: else resultSet.copy(indices_ptr, dists_ptr, n); } - return resultSet.size(); + return (int)resultSet.size(); } /** diff --git a/modules/flann/include/opencv2/flann/sampling.h b/modules/flann/include/opencv2/flann/sampling.h index fd65150..396f177 100644 --- a/modules/flann/include/opencv2/flann/sampling.h +++ b/modules/flann/include/opencv2/flann/sampling.h @@ -43,7 +43,7 @@ Matrix random_sample(Matrix& srcMatrix, long size, bool remove = false) T* src,* dest; for (long i=0; i random_sample(Matrix& srcMatrix, long size, bool remove = false) template Matrix random_sample(const Matrix& srcMatrix, size_t size) { - UniqueRandom rand(srcMatrix.rows); + UniqueRandom rand((int)srcMatrix.rows); Matrix newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols); T* src,* dest; diff --git a/modules/flann/src/flann.cpp b/modules/flann/src/flann.cpp index 36ee669..85ccdc7 100644 --- a/modules/flann/src/flann.cpp +++ b/modules/flann/src/flann.cpp @@ -27,6 +27,10 @@ *************************************************************************/ #include "precomp.hpp" + +#ifdef _MSC_VER +#pragma warning(disable: 4996) +#endif #include "opencv2/flann/flann.hpp" namespace cvflann diff --git a/modules/flann/src/precomp.hpp b/modules/flann/src/precomp.hpp index 72731af..cebe286 100644 --- a/modules/flann/src/precomp.hpp +++ b/modules/flann/src/precomp.hpp @@ -5,6 +5,10 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable: 4996) +#endif + #ifdef HAVE_CVCONFIG_H # include "cvconfig.h" #endif diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index d0daec7..19c9194 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -47,6 +47,7 @@ #if defined _M_X64 && defined _MSC_VER && !defined CV_ICC #pragma optimize("",off) +#pragma warning( disable: 4748 ) #endif namespace cv diff --git a/modules/highgui/src/cap_vfw.cpp b/modules/highgui/src/cap_vfw.cpp index 8721148..059be19 100644 --- a/modules/highgui/src/cap_vfw.cpp +++ b/modules/highgui/src/cap_vfw.cpp @@ -54,6 +54,7 @@ #if defined _M_X64 #pragma optimize("",off) +#pragma warning(disable: 4748) #endif /********************* Capturing video from AVI via VFW ************************/ diff --git a/modules/highgui/src/grfmt_jpeg.cpp b/modules/highgui/src/grfmt_jpeg.cpp index 46a20b9..183a38e 100644 --- a/modules/highgui/src/grfmt_jpeg.cpp +++ b/modules/highgui/src/grfmt_jpeg.cpp @@ -44,6 +44,10 @@ #ifdef HAVE_JPEG +#ifdef _MSC_VER +#pragma warning(disable: 4324 4611) +#endif + #include #include diff --git a/modules/highgui/test/test_positioning.cpp b/modules/highgui/test/test_positioning.cpp index fec0a07..358145a 100644 --- a/modules/highgui/test/test_positioning.cpp +++ b/modules/highgui/test/test_positioning.cpp @@ -148,7 +148,7 @@ void CV_VideoPositioningTest::run_test(int method) generate_idx_seq(cap, method); - int N = idx.size(), failed_frames = 0, failed_positions = 0, failed_iterations = 0; + int N = (int)idx.size(), failed_frames = 0, failed_positions = 0, failed_iterations = 0; for (int j = 0; j < N; ++j) { diff --git a/modules/imgproc/perf/perf_filter2d.cpp b/modules/imgproc/perf/perf_filter2d.cpp index c87f31c..f012096 100644 --- a/modules/imgproc/perf/perf_filter2d.cpp +++ b/modules/imgproc/perf/perf_filter2d.cpp @@ -32,7 +32,7 @@ PERF_TEST_P( TestFilter2d, Filter2d, Mat kernel(kSize, kSize, CV_32FC1); randu(kernel, -3, 10); - float s = fabs( sum(kernel)[0] ); + double s = fabs( sum(kernel)[0] ); if(s > 1e-3) kernel /= s; declare.in(src, WARMUP_RNG).out(dst).time(20); diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 82df50d..f1d60df 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -3216,36 +3216,37 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) const uchar* y = src.ptr(); const uchar* uv = y + dstSz.area(); + int srcstep = (int)src.step; // http://www.fourcc.org/yuv.php#NV21 == yuv420sp -> a plane of 8 bit Y samples followed by an interleaved V/U plane containing 8 bit 2x2 subsampled chroma samples // http://www.fourcc.org/yuv.php#NV12 == yvu420sp -> a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples if (CV_YUV420sp2RGB == code || COLOR_YUV420sp2RGBA == code) { if (dcn == 3) - cvtYUV4202RGB<2, 1>(dst, src.step, y, uv); + cvtYUV4202RGB<2, 1>(dst, srcstep, y, uv); else - cvtYUV4202RGBA<2, 1>(dst, src.step, y, uv); + cvtYUV4202RGBA<2, 1>(dst, srcstep, y, uv); } else if (CV_YUV420sp2BGR == code || CV_YUV420sp2BGRA == code) { if (dcn == 3) - cvtYUV4202RGB<0, 1>(dst, src.step, y, uv); + cvtYUV4202RGB<0, 1>(dst, srcstep, y, uv); else - cvtYUV4202RGBA<0, 1>(dst, src.step, y, uv); + cvtYUV4202RGBA<0, 1>(dst, srcstep, y, uv); } else if (CV_YUV2RGB_NV12 == code || CV_YUV2RGBA_NV12 == code) { if (dcn == 3) - cvtYUV4202RGB<2, 0>(dst, src.step, y, uv); + cvtYUV4202RGB<2, 0>(dst, srcstep, y, uv); else - cvtYUV4202RGBA<2, 0>(dst, src.step, y, uv); + cvtYUV4202RGBA<2, 0>(dst, srcstep, y, uv); } else //if (CV_YUV2BGR_NV12 == code || CV_YUV2BGRA_NV12 == code) { if (dcn == 3) - cvtYUV4202RGB<0, 0>(dst, src.step, y, uv); + cvtYUV4202RGB<0, 0>(dst, srcstep, y, uv); else - cvtYUV4202RGBA<0, 0>(dst, src.step, y, uv); + cvtYUV4202RGBA<0, 0>(dst, srcstep, y, uv); } } break; diff --git a/modules/imgproc/src/gabor.cpp b/modules/imgproc/src/gabor.cpp index 5a81312..4cbbd24 100644 --- a/modules/imgproc/src/gabor.cpp +++ b/modules/imgproc/src/gabor.cpp @@ -60,12 +60,12 @@ cv::Mat cv::getGaborKernel( Size ksize, double sigma, double theta, if( ksize.width > 0 ) xmax = ksize.width/2; else - xmax = std::max(fabs(nstds*sigma_x*c), fabs(nstds*sigma_y*s)); + xmax = cvRound(std::max(fabs(nstds*sigma_x*c), fabs(nstds*sigma_y*s))); if( ksize.height > 0 ) ymax = ksize.height/2; else - ymax = std::max(fabs(nstds*sigma_x*s), fabs(nstds*sigma_y*c)); + ymax = cvRound(std::max(fabs(nstds*sigma_x*s), fabs(nstds*sigma_y*c))); xmin = -xmax; ymin = -ymax; diff --git a/modules/imgproc/src/geometry.cpp b/modules/imgproc/src/geometry.cpp index 66d0291..95aa540 100644 --- a/modules/imgproc/src/geometry.cpp +++ b/modules/imgproc/src/geometry.cpp @@ -439,8 +439,8 @@ static char segSegInt( Point2f a, Point2f b, Point2f c, Point2f d, Point2f& p, P (0.0 > t) || (t > 1.0) ) code = '0'; - p.x = a.x + s * ( b.x - a.x ); - p.y = a.y + s * ( b.y - a.y ); + p.x = (float)(a.x + s*(b.x - a.x)); + p.y = (float)(a.y + s*(b.y - a.y)); return code; } @@ -652,7 +652,7 @@ float cv::intersectConvexConvex( InputArray _p1, InputArray _p2, OutputArray _p1 _p12.release(); return 0.f; } - area = contourArea(_InputArray(result, nr), false); + area = (float)contourArea(_InputArray(result, nr), false); } if( _p12.needed() ) diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index 98052f7..06fd5ba 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -1079,9 +1079,9 @@ public: int row0 = min(cvRound(range.begin() * src.rows / nStripes), src.rows); int row1 = min(cvRound(range.end() * src.rows / nStripes), src.rows); - if(0) + /*if(0) printf("Size = (%d, %d), range[%d,%d), row0 = %d, row1 = %d\n", - src.rows, src.cols, range.begin(), range.end(), row0, row1); + src.rows, src.cols, range.begin(), range.end(), row0, row1);*/ Mat srcStripe = src.rowRange(row0, row1); Mat dstStripe = dst.rowRange(row0, row1); @@ -1105,7 +1105,7 @@ private: Point anchor; int rowBorderType; int columnBorderType; - const Scalar& borderValue; + Scalar borderValue; }; static void morphOp( int op, InputArray _src, OutputArray _dst, diff --git a/modules/imgproc/src/phasecorr.cpp b/modules/imgproc/src/phasecorr.cpp index 130fe91..26b7c5c 100644 --- a/modules/imgproc/src/phasecorr.cpp +++ b/modules/imgproc/src/phasecorr.cpp @@ -571,33 +571,30 @@ void cv::createHanningWindow(OutputArray _dst, cv::Size winSize, int type) int rows = dst.rows; int cols = dst.cols; - int step = dst.step/dst.elemSize1(); if(dst.depth() == CV_32F) { - float* dstData = dst.ptr(); - for(int i = 0; i < rows; i++) { + float* dstData = dst.ptr(i); double wr = 0.5 * (1.0f - cos(2.0f * CV_PI * (double)i / (double)(rows - 1))); for(int j = 0; j < cols; j++) { double wc = 0.5 * (1.0f - cos(2.0f * CV_PI * (double)j / (double)(cols - 1))); - dstData[i*step + j] = (float)(wr * wc); + dstData[j] = (float)(wr * wc); } } } else { - double* dstData = dst.ptr(); - for(int i = 0; i < rows; i++) { + double* dstData = dst.ptr(i); double wr = 0.5 * (1.0 - cos(2.0 * CV_PI * (double)i / (double)(rows - 1))); for(int j = 0; j < cols; j++) { double wc = 0.5 * (1.0 - cos(2.0 * CV_PI * (double)j / (double)(cols - 1))); - dstData[i*step + j] = wr * wc; + dstData[j] = wr * wc; } } } diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index 0e36117..8b7ce8e 100644 --- a/modules/imgproc/src/thresh.cpp +++ b/modules/imgproc/src/thresh.cpp @@ -687,9 +687,9 @@ public: int row0 = std::min(cvRound(range.begin() * src.rows / nStripes), src.rows); int row1 = std::min(cvRound(range.end() * src.rows / nStripes), src.rows); - if(0) + /*if(0) printf("Size = (%d, %d), range[%d,%d), row0 = %d, row1 = %d\n", - src.rows, src.cols, range.begin(), range.end(), row0, row1); + src.rows, src.cols, range.begin(), range.end(), row0, row1);*/ Mat srcStripe = src.rowRange(row0, row1); Mat dstStripe = dst.rowRange(row0, row1); diff --git a/modules/imgproc/test/test_boundingrect.cpp b/modules/imgproc/test/test_boundingrect.cpp index eeca50a..e8d760c 100644 --- a/modules/imgproc/test/test_boundingrect.cpp +++ b/modules/imgproc/test/test_boundingrect.cpp @@ -77,7 +77,7 @@ template void CV_BoundingRectTest::generate_src_points(vector cv::Rect CV_BoundingRectTest::get_bounding_rect(const vector > src) { - int n = src.size(); + int n = (int)src.size(); T min_w = std::numeric_limits::max(), max_w = std::numeric_limits::min(); T min_h = min_w, max_h = max_w; diff --git a/modules/legacy/include/opencv2/legacy/legacy.hpp b/modules/legacy/include/opencv2/legacy/legacy.hpp index 7b1184d..c0d1872 100644 --- a/modules/legacy/include/opencv2/legacy/legacy.hpp +++ b/modules/legacy/include/opencv2/legacy/legacy.hpp @@ -2717,7 +2717,7 @@ void CalonderDescriptorExtractor::computeImpl( const Mat& image, KeyPointsFilter::runByImageBorder(keypoints, image.size(), BORDER_SIZE); /// @todo Check 16-byte aligned - descriptors.create(keypoints.size(), classifier_.classes(), cv::DataType::type); + descriptors.create((int)keypoints.size(), classifier_.classes(), cv::DataType::type); int patchSize = RandomizedTree::PATCH_SIZE; int offset = patchSize / 2; @@ -2725,7 +2725,7 @@ void CalonderDescriptorExtractor::computeImpl( const Mat& image, { cv::Point2f pt = keypoints[i].pt; IplImage ipl = image( Rect((int)(pt.x - offset), (int)(pt.y - offset), patchSize, patchSize) ); - classifier_.getSignature( &ipl, descriptors.ptr(i)); + classifier_.getSignature( &ipl, descriptors.ptr((int)i)); } } diff --git a/modules/legacy/src/features2d.cpp b/modules/legacy/src/features2d.cpp index 94097bd..e9cbc34 100644 --- a/modules/legacy/src/features2d.cpp +++ b/modules/legacy/src/features2d.cpp @@ -89,7 +89,7 @@ cvExtractSURF( const CvArr* _img, const CvArr* _mask, *_keypoints = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvSURFPoint), storage); if( _descriptors ) - *_descriptors = cvCreateSeq( 0, sizeof(CvSeq), descr.cols*descr.elemSize(), storage ); + *_descriptors = cvCreateSeq(0, sizeof(CvSeq), descr.cols*descr.elemSize(), storage); for( size_t i = 0; i < kpt.size(); i++ ) { @@ -99,7 +99,7 @@ cvExtractSURF( const CvArr* _img, const CvArr* _mask, cvSeqPush(*_keypoints, &pt); } if( _descriptors ) - cvSeqPush(*_descriptors, descr.ptr(i)); + cvSeqPush(*_descriptors, descr.ptr((int)i)); } } diff --git a/modules/nonfree/src/sift.cpp b/modules/nonfree/src/sift.cpp index 0e289f1..bb5e1ef 100644 --- a/modules/nonfree/src/sift.cpp +++ b/modules/nonfree/src/sift.cpp @@ -275,8 +275,8 @@ static float calcOrientationHist( const Mat& img, Point pt, int radius, if( x <= 0 || x >= img.cols - 1 ) continue; - float dx = img.at(y, x+1) - img.at(y, x-1); - float dy = img.at(y-1, x) - img.at(y+1, x); + float dx = (float)(img.at(y, x+1) - img.at(y, x-1)); + float dy = (float)(img.at(y-1, x) - img.at(y+1, x)); X[k] = dx; Y[k] = dy; W[k] = (i*i + j*j)*expf_scale; k++; @@ -347,7 +347,7 @@ static bool adjustLocalExtrema( const vector& dog_pyr, KeyPoint& kpt, int o (img.at(r+1, c) - img.at(r-1, c))*deriv_scale, (next.at(r, c) - prev.at(r, c))*deriv_scale); - float v2 = img.at(r, c)*2; + float v2 = (float)img.at(r, c)*2; float dxx = (img.at(r, c+1) + img.at(r, c-1) - v2)*second_deriv_scale; float dyy = (img.at(r+1, c) + img.at(r-1, c) - v2)*second_deriv_scale; float dss = (next.at(r, c) + prev.at(r, c) - v2)*second_deriv_scale; @@ -400,7 +400,7 @@ static bool adjustLocalExtrema( const vector& dog_pyr, KeyPoint& kpt, int o return false; /* principal curvatures are computed using the trace and det of Hessian */ - float v2 = img.at(r, c)*2; + float v2 = img.at(r, c)*2.f; float dxx = (img.at(r, c+1) + img.at(r, c-1) - v2)*second_deriv_scale; float dyy = (img.at(r+1, c) + img.at(r-1, c) - v2)*second_deriv_scale; float dxy = (img.at(r+1, c+1) - img.at(r+1, c-1) - @@ -477,8 +477,9 @@ void SIFT::findScaleSpaceExtrema( const vector& gauss_pyr, const vector -1 && rbin < d && cbin > -1 && cbin < d && r > 0 && r < rows - 1 && c > 0 && c < cols - 1 ) { - float dx = img.at(r, c+1) - img.at(r, c-1); - float dy = img.at(r-1, c) - img.at(r+1, c); + float dx = (float)(img.at(r, c+1) - img.at(r, c-1)); + float dy = (float)(img.at(r-1, c) - img.at(r+1, c)); X[k] = dx; Y[k] = dy; RBin[k] = rbin; CBin[k] = cbin; W[k] = (c_rot * c_rot + r_rot * r_rot)*exp_scale; k++; @@ -648,7 +649,7 @@ static void calcDescriptors(const vector& gpyr, const vector& key Point2f ptf(kpt.pt.x*scale, kpt.pt.y*scale); const Mat& img = gpyr[octv*(nOctaveLayers + 3) + layer]; - calcSIFTDescriptor(img, ptf, kpt.angle, size*0.5f, d, n, descriptors.ptr(i)); + calcSIFTDescriptor(img, ptf, kpt.angle, size*0.5f, d, n, descriptors.ptr((int)i)); } } @@ -714,7 +715,7 @@ void SIFT::operator()(InputArray _image, InputArray _mask, if( !mask.empty() && mask.type() != CV_8UC1 ) CV_Error( CV_StsBadArg, "mask has incorrect type (!=CV_8UC1)" ); - Mat base = createInitialImage(image, false, sigma); + Mat base = createInitialImage(image, false, (float)sigma); vector gpyr, dogpyr; int nOctaves = cvRound(log( (double)std::min( base.cols, base.rows ) ) / log(2.) - 2); diff --git a/modules/nonfree/src/surf.cpp b/modules/nonfree/src/surf.cpp index 61a248c..8e2c1a8 100644 --- a/modules/nonfree/src/surf.cpp +++ b/modules/nonfree/src/surf.cpp @@ -252,7 +252,7 @@ interpolateKeypoint( float N9[3][9], int dx, int dy, int ds, KeyPoint& kpt ) { kpt.pt.x += x(0,0)*dx; kpt.pt.y += x(1,0)*dy; - kpt.size = cvRound( kpt.size + x(2,0)*ds ); + kpt.size = (float)cvRound( kpt.size + x(2,0)*ds ); } return ok; } @@ -341,7 +341,8 @@ findMaximaInLayer( const Mat& sum, const Mat& mask_sum, float center_i = sum_i + (size-1)*0.5f; float center_j = sum_j + (size-1)*0.5f; - KeyPoint kpt( center_j, center_i, sizes[layer], -1, val0, octave, CV_SIGN(trace_ptr[j]) ); + KeyPoint kpt( center_j, center_i, (float)sizes[layer], + -1, val0, octave, CV_SIGN(trace_ptr[j]) ); /* Interpolate maxima location within the 3x3x3 neighbourhood */ int ds = size - sizes[layer-1]; @@ -561,8 +562,8 @@ struct SURFInvoker { maxSize = std::max(maxSize, (*keypoints)[k].size); } - maxSize = cvCeil((PATCH_SZ+1)*maxSize*1.2f/9.0f); - Ptr winbuf = cvCreateMat( 1, maxSize > 0 ? maxSize*maxSize : 1, CV_8U ); + int imaxSize = std::max(cvCeil((PATCH_SZ+1)*maxSize*1.2f/9.0f), 1); + Ptr winbuf = cvCreateMat( 1, imaxSize*imaxSize, CV_8U ); for( k = k1; k < k2; k++ ) { int i, j, kk, x, y, nangle; @@ -863,7 +864,7 @@ void SURF::operator()(InputArray _img, InputArray _mask, cv::min(mask, 1, mask1); integral(mask1, msum, CV_32S); } - fastHessianDetector( sum, msum, keypoints, nOctaves, nOctaveLayers, hessianThreshold ); + fastHessianDetector( sum, msum, keypoints, nOctaves, nOctaveLayers, (float)hessianThreshold ); } int i, j, N = (int)keypoints.size(); diff --git a/modules/nonfree/test/test_detectors.cpp b/modules/nonfree/test/test_detectors.cpp index 75bc521..d9f7a8e 100644 --- a/modules/nonfree/test/test_detectors.cpp +++ b/modules/nonfree/test/test_detectors.cpp @@ -297,7 +297,7 @@ void CV_DetectorsTest::run( int /*start_from*/ ) if (exp.empty()) return; - if (!testDetector(to_test, SurfNoMaskWrap(SURF(1536+512+512, 2)), exp)) + if (!testDetector(to_test, SurfNoMaskWrap(SURF(1536+512+512, true, false, 2)), exp)) return; LoadExpected(string(ts->get_data_path()) + "detectors/star.xml", exp); diff --git a/modules/objdetect/src/latentsvmdetector.cpp b/modules/objdetect/src/latentsvmdetector.cpp index 806a13d..4243be2 100644 --- a/modules/objdetect/src/latentsvmdetector.cpp +++ b/modules/objdetect/src/latentsvmdetector.cpp @@ -201,7 +201,7 @@ string extractModelName( const string& filename ) const int extentionSize = 4; //.xml - int substrLength = filename.size() - startPos - extentionSize; + int substrLength = (int)(filename.size() - startPos - extentionSize); return filename.substr(startPos, substrLength); } diff --git a/modules/objdetect/src/linemod.cpp b/modules/objdetect/src/linemod.cpp index 67a7e18..23ec579 100644 --- a/modules/objdetect/src/linemod.cpp +++ b/modules/objdetect/src/linemod.cpp @@ -66,7 +66,7 @@ static inline int getLabel(int quantized) case 64: return 6; case 128: return 7; default: - CV_Assert(false); + CV_Error(CV_StsBadArg, "Invalid value of quantized parameter"); return -1; //avoid warning } } diff --git a/modules/stitching/include/opencv2/stitching/detail/warpers_inl.hpp b/modules/stitching/include/opencv2/stitching/detail/warpers_inl.hpp index ec4af53..edfc9c3 100644 --- a/modules/stitching/include/opencv2/stitching/detail/warpers_inl.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/warpers_inl.hpp @@ -306,7 +306,7 @@ void FisheyeProjector::mapForward(float x, float y, float &u, float &v) float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; float u_ = atan2f(x_, z_); - float v_ = CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + float v_ = (float)CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); u = scale * v_ * cosf(u_); v = scale * v_ * sinf(u_); @@ -321,9 +321,9 @@ void FisheyeProjector::mapBackward(float u, float v, float &x, float &y) float u_ = atan2f(v, u); float v_ = sqrtf(u*u + v*v); - float sinv = sinf(CV_PI - v_); + float sinv = sinf((float)CV_PI - v_); float x_ = sinv * sinf(u_); - float y_ = cosf(CV_PI - v_); + float y_ = cosf((float)CV_PI - v_); float z_ = sinv * cosf(u_); float z; @@ -343,7 +343,7 @@ void StereographicProjector::mapForward(float x, float y, float &u, float &v) float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; float u_ = atan2f(x_, z_); - float v_ = CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + float v_ = (float)CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); float r = sinf(v_) / (1 - cosf(v_)); @@ -359,11 +359,11 @@ void StereographicProjector::mapBackward(float u, float v, float &x, float &y) float u_ = atan2f(v, u); float r = sqrtf(u*u + v*v); - float v_ = 2 * atanf(1.0 / r); + float v_ = 2 * atanf(1.f / r); - float sinv = sinf(CV_PI - v_); + float sinv = sinf((float)CV_PI - v_); float x_ = sinv * sinf(u_); - float y_ = cosf(CV_PI - v_); + float y_ = cosf((float)CV_PI - v_); float z_ = sinv * cosf(u_); float z; @@ -560,7 +560,7 @@ void MercatorProjector::mapForward(float x, float y, float &u, float &v) float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); u = scale * u_; - v = scale * logf( tanf( CV_PI/4 + v_/2 ) ); + v = scale * logf( tanf( (float)(CV_PI/4) + v_/2 ) ); } inline diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index 048de6c..ad697f9 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -376,7 +376,7 @@ void OrbFeaturesFinder::find(const Mat &image, ImageFeatures &features) } else if (image.type() == CV_8UC1) { gray_image=image; } else { - CV_Assert(false); + CV_Error(CV_StsUnsupportedFormat, ""); } if (grid_size.area() == 1) diff --git a/modules/stitching/src/motion_estimators.cpp b/modules/stitching/src/motion_estimators.cpp index acf2ad6c..f061059 100644 --- a/modules/stitching/src/motion_estimators.cpp +++ b/modules/stitching/src/motion_estimators.cpp @@ -700,7 +700,7 @@ string matchesGraphAsString(vector &pathes, vector &pairwis for (size_t i = 0; i < comps.size.size(); ++i) { - if (comps.size[comps.findSetByElem(i)] == 1) + if (comps.size[comps.findSetByElem((int)i)] == 1) { string name = pathes[i]; size_t prefix_len = name.find_last_of("/\\"); diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp index a03d4ac..b0ad8f1 100644 --- a/modules/stitching/src/stitcher.cpp +++ b/modules/stitching/src/stitcher.cpp @@ -268,7 +268,7 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano) warper->warp(mask, K, cameras_[img_idx].R, INTER_NEAREST, BORDER_CONSTANT, mask_warped); // Compensate exposure - exposure_comp_->apply(img_idx, corners[img_idx], img_warped, mask_warped); + exposure_comp_->apply((int)img_idx, corners[img_idx], img_warped, mask_warped); img_warped.convertTo(img_warped_s, CV_16S); img_warped.release(); @@ -374,7 +374,7 @@ Stitcher::Status Stitcher::matchImages() (*features_finder_)(img, features_[i]); else (*features_finder_)(img, features_[i], rois_[i]); - features_[i].img_idx = i; + features_[i].img_idx = (int)i; LOGLN("Features in image #" << i+1 << ": " << features_[i].keypoints.size()); resize(full_img, img, Size(), seam_scale_, seam_scale_); diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index f0fb361..415fdd5 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -8,7 +8,7 @@ void randu(cv::Mat& m) if (m.depth() < CV_32F) { int minmax[] = {0, 256}; - cv::Mat mr = cv::Mat(m.rows, m.cols * m.elemSize(), CV_8U, m.ptr(), m.step[0]); + cv::Mat mr = cv::Mat(m.rows, (int)(m.cols * m.elemSize()), CV_8U, m.ptr(), m.step[0]); cv::randu(mr, cv::Mat(1, 1, CV_32S, minmax), cv::Mat(1, 1, CV_32S, minmax + 1)); } else if (m.depth() == CV_32F) @@ -66,7 +66,7 @@ void Regression::init(const std::string& testSuitName, const std::string& ext) if (data_path_dir) { - int len = strlen(data_path_dir)-1; + int len = (int)strlen(data_path_dir)-1; if (len < 0) len = 0; std::string path_base = (data_path_dir[0] == 0 ? std::string(".") : std::string(data_path_dir)) + (data_path_dir[len] == '/' || data_path_dir[len] == '\\' ? "" : path_separator) @@ -260,7 +260,7 @@ void Regression::write(cv::InputArray array) write() << "type" << array.type(); if (isVector(array)) { - int total = array.total(); + int total = (int)array.total(); int idx = regRNG.uniform(0, total); write() << "len" << total; write() << "idx" << idx; @@ -586,7 +586,7 @@ void TestBase::warmup(cv::InputOutputArray a, int wtype) { size_t total = a.total(); for (size_t i = 0; i < total; ++i) - warmup_impl(a.getMat(i), wtype); + warmup_impl(a.getMat((int)i), wtype); } } @@ -908,7 +908,7 @@ std::string TestBase::getDataPath(const std::string& relativePath) std::string path; if (data_path_dir) { - int len = strlen(data_path_dir) - 1; + int len = (int)strlen(data_path_dir) - 1; if (len < 0) len = 0; path = (data_path_dir[0] == 0 ? std::string(".") : std::string(data_path_dir)) + (data_path_dir[len] == '/' || data_path_dir[len] == '\\' ? "" : path_separator); diff --git a/samples/c/blobtrack_sample.cpp b/samples/c/blobtrack_sample.cpp index 78c8328..a7b7866 100644 --- a/samples/c/blobtrack_sample.cpp +++ b/samples/c/blobtrack_sample.cpp @@ -292,7 +292,7 @@ static int RunBlobTrackingAuto( CvCapture* pCap, CvBlobTrackerAuto* pTracker,cha */ static void set_params(int argc, char* argv[], CvVSModule* pM, const char* prefix, const char* module) { - int prefix_len = strlen(prefix); + int prefix_len = (int)strlen(prefix); int i; for(i=0; iGetParamName(j); if(param==NULL) break; - param_len = strlen(param); + param_len = (int)strlen(param); if(cmd_param_len!=param_len) continue; if(MY_STRNICMP(param,cmd,param_len)!=0) continue; cmd+=param_len; diff --git a/samples/c/mushroom.cpp b/samples/c/mushroom.cpp index 67bbaa6..2230912 100644 --- a/samples/c/mushroom.cpp +++ b/samples/c/mushroom.cpp @@ -202,7 +202,7 @@ void print_variable_importance( CvDTree* dtree, const char** var_desc ) if( var_desc ) { char buf[100]; - int len = strchr( var_desc[i], '(' ) - var_desc[i] - 1; + int len = (int)(strchr( var_desc[i], '(' ) - var_desc[i] - 1); strncpy( buf, var_desc[i], len ); buf[len] = '\0'; printf( "%s", buf ); diff --git a/samples/c/tree_engine.cpp b/samples/c/tree_engine.cpp index 2517953..48ba10e 100644 --- a/samples/c/tree_engine.cpp +++ b/samples/c/tree_engine.cpp @@ -32,7 +32,7 @@ int count_classes(CvMLData& data) return -1; rmap[ival] = 1; } - return rmap.size(); + return (int)rmap.size(); } void print_result(float train_err, float test_err, const CvMat* _var_imp) diff --git a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp index f6e5d26..7dcb99b 100644 --- a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp +++ b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp @@ -131,8 +131,7 @@ void drawPlot(const cv::Mat curve, const std::string figureTitle, const int lowe int localAdaptation_photoreceptors, localAdaptation_Gcells; void callBack_updateRetinaParams(int, void*) { - - retina->setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (double)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0)); + retina->setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (float)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0)); } int colorSaturationFactor; diff --git a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp index 85b2dc6..134b4c7 100644 --- a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp +++ b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp @@ -134,8 +134,8 @@ void rescaleGrayLevelMat(const cv::Mat &inputMat, cv::Mat &outputMat, const floa { inputMat.copyTo(outputMat); // update threshold in the initial input image range - maxInputValue=(maxInputValue-255.f)/histNormRescalefactor+maxInput; - minInputValue=minInputValue/histNormRescalefactor+minInput; + maxInputValue=(float)((maxInputValue-255.f)/histNormRescalefactor+maxInput); + minInputValue=(float)(minInputValue/histNormRescalefactor+minInput); std::cout<<"===> Input Hist clipping values (max,min) = "<setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (double)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0)); + retina->setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (float)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0)); } int colorSaturationFactor; @@ -211,8 +210,8 @@ void loadNewFrame(const std::string filenamePrototype, const int currentFileInde double maxInput, minInput; minMaxLoc(inputImage, &minInput, &maxInput); std::cout<<"FIRST IMAGE pixels values range (max,min) : "<(),(char)1)); + total_relevant = (int)std::count_if(ground_truth.begin(),ground_truth.end(),std::bind2nd(std::equal_to(),(char)1)); } /* iterate through images */ @@ -1040,7 +1040,7 @@ void VocData::calcClassifierConfMatRow(const string& obj_class, const vector(img_objects.size()); } @@ -1174,7 +1174,7 @@ void VocData::calcDetectorConfMatRow(const string& obj_class, const ObdDatasetTy if (ov > maxov) { maxov = ov; - max_gt_obj_idx = gt_obj_idx; + max_gt_obj_idx = (int)gt_obj_idx; } } } @@ -1192,7 +1192,7 @@ void VocData::calcDetectorConfMatRow(const string& obj_class, const ObdDatasetTy CV_Error(CV_StsError,err_msg.c_str()); } /* convert iterator to index */ - int class_idx = std::distance(output_headers.begin(),class_idx_it); + int class_idx = (int)std::distance(output_headers.begin(),class_idx_it); //add to confusion matrix row in proportion output_values[class_idx] += 1.0; } else { @@ -1540,7 +1540,7 @@ void VocData::readDetectorResultsFile(const string& input_file, vector& bounding_boxes.push_back(bounding_box_vect); } else { /* if the image index has been seen before, add the current object below it in the 2D arrays */ - int image_idx = std::distance(image_codes.begin(),image_codes_it); + int image_idx = (int)std::distance(image_codes.begin(),image_codes_it); scores[image_idx].push_back(score); bounding_boxes[image_idx].push_back(bounding_box); } @@ -1985,7 +1985,7 @@ struct VocabTrainParams { VocabTrainParams() : trainObjClass("chair"), vocabSize(1000), memoryUse(200), descProportion(0.3f) {} VocabTrainParams( const string _trainObjClass, size_t _vocabSize, size_t _memoryUse, float _descProportion ) : - trainObjClass(_trainObjClass), vocabSize(_vocabSize), memoryUse(_memoryUse), descProportion(_descProportion) {} + trainObjClass(_trainObjClass), vocabSize((int)_vocabSize), memoryUse((int)_memoryUse), descProportion(_descProportion) {} void read( const FileNode& fn ) { fn["trainObjClass"] >> trainObjClass; @@ -2154,7 +2154,7 @@ Mat trainVocabulary( const string& filename, VocData& vocData, const VocabTrainP // Randomly pick an image from the dataset which hasn't yet been seen // and compute the descriptors from that image. - int randImgIdx = rng( images.size() ); + int randImgIdx = rng( (unsigned)images.size() ); Mat colorImage = imread( images[randImgIdx].path ); vector imageKeypoints; fdetector->detect( colorImage, imageKeypoints ); @@ -2296,12 +2296,12 @@ void removeBowImageDescriptorsByCount( vector& images, vector bow const SVMTrainParamsExt& svmParamsExt, int descsToDelete ) { RNG& rng = theRNG(); - int pos_ex = std::count( objectPresent.begin(), objectPresent.end(), (char)1 ); - int neg_ex = std::count( objectPresent.begin(), objectPresent.end(), (char)0 ); + int pos_ex = (int)std::count( objectPresent.begin(), objectPresent.end(), (char)1 ); + int neg_ex = (int)std::count( objectPresent.begin(), objectPresent.end(), (char)0 ); while( descsToDelete != 0 ) { - int randIdx = rng(images.size()); + int randIdx = rng((unsigned)images.size()); // Prefer positive training examples according to svmParamsExt.targetRatio if required if( objectPresent[randIdx] ) @@ -2415,14 +2415,14 @@ void trainSVMClassifier( CvSVM& svm, const SVMTrainParamsExt& svmParamsExt, cons } // Prepare the input matrices for SVM training. - Mat trainData( images.size(), bowExtractor->getVocabulary().rows, CV_32FC1 ); - Mat responses( images.size(), 1, CV_32SC1 ); + Mat trainData( (int)images.size(), bowExtractor->getVocabulary().rows, CV_32FC1 ); + Mat responses( (int)images.size(), 1, CV_32SC1 ); // Transfer bag of words vectors and responses across to the training data matrices for( size_t imageIdx = 0; imageIdx < images.size(); imageIdx++ ) { // Transfer image descriptor (bag of words vector) to training data matrix - Mat submat = trainData.row(imageIdx); + Mat submat = trainData.row((int)imageIdx); if( bowImageDescriptors[imageIdx].cols != bowExtractor->descriptorSize() ) { cout << "Error: computed bow image descriptor size " << bowImageDescriptors[imageIdx].cols @@ -2432,7 +2432,7 @@ void trainSVMClassifier( CvSVM& svm, const SVMTrainParamsExt& svmParamsExt, cons bowImageDescriptors[imageIdx].copyTo( submat ); // Set response value - responses.at(imageIdx) = objectPresent[imageIdx] ? 1 : -1; + responses.at((int)imageIdx) = objectPresent[imageIdx] ? 1 : -1; } cout << "TRAINING SVM FOR CLASS ..." << objClassName << "..." << endl; diff --git a/samples/cpp/calibration.cpp b/samples/cpp/calibration.cpp index ba5c210..bfa91cd 100644 --- a/samples/cpp/calibration.cpp +++ b/samples/cpp/calibration.cpp @@ -232,7 +232,7 @@ void saveCameraParams( const string& filename, if( !imagePoints.empty() ) { - Mat imagePtMat((int)imagePoints.size(), imagePoints[0].size(), CV_32FC2); + Mat imagePtMat((int)imagePoints.size(), (int)imagePoints[0].size(), CV_32FC2); for( int i = 0; i < (int)imagePoints.size(); i++ ) { Mat r = imagePtMat.row(i).reshape(2, imagePtMat.cols); diff --git a/samples/cpp/ffilldemo.cpp b/samples/cpp/ffilldemo.cpp index 9730483..063860a 100644 --- a/samples/cpp/ffilldemo.cpp +++ b/samples/cpp/ffilldemo.cpp @@ -95,11 +95,13 @@ int main( int argc, char** argv ) imshow("image", isColor ? image : gray); int c = waitKey(0); - switch( (char)c ) + if( (c & 255) == 27 ) { - case 27: cout << "Exiting ...\n"; - return 0; + break; + } + switch( (char)c ) + { case 'c': if( isColor ) { diff --git a/samples/cpp/hybridtrackingsample.cpp b/samples/cpp/hybridtrackingsample.cpp index 24765ff..3096dc0 100644 --- a/samples/cpp/hybridtrackingsample.cpp +++ b/samples/cpp/hybridtrackingsample.cpp @@ -103,12 +103,12 @@ int main(int argc, char** argv) HybridTrackerParams params; // motion model params params.motion_model = CvMotionModel::LOW_PASS_FILTER; - params.low_pass_gain = 0.1; + params.low_pass_gain = 0.1f; // mean shift params - params.ms_tracker_weight = 0.8; + params.ms_tracker_weight = 0.8f; params.ms_params.tracking_type = CvMeanShiftTrackerParams::HS; // feature tracking params - params.ft_tracker_weight = 0.2; + params.ft_tracker_weight = 0.2f; params.ft_params.feature_type = CvFeatureTrackerParams::OPTICAL_FLOW; params.ft_params.window_size = 0; @@ -121,12 +121,14 @@ int main(int argc, char** argv) int i = 0; float w[4]; - while(1) + for(;;) { i++; if (live) { cap >> frame; + if( frame.empty() ) + break; frame.copyTo(image); } else @@ -134,12 +136,12 @@ int main(int argc, char** argv) fscanf(f, "%d %f %f %f %f\n", &i, &w[0], &w[1], &w[2], &w[3]); sprintf(img_file, "seqG/%04d.png", i); image = imread(img_file, CV_LOAD_IMAGE_COLOR); - selection = Rect(w[0]*image.cols, w[1]*image.rows, w[2]*image.cols, w[3]*image.rows); + if (image.empty()) + break; + selection = Rect(cvRound(w[0]*image.cols), cvRound(w[1]*image.rows), + cvRound(w[2]*image.cols), cvRound(w[3]*image.rows)); } - if (image.data == NULL) - continue; - sprintf(img_file_num, "Frame: %d", i); putText(image, img_file_num, Point(10, image.rows-20), FONT_HERSHEY_PLAIN, 0.75, Scalar(255, 255, 255)); if (!image.empty()) @@ -163,7 +165,8 @@ int main(int argc, char** argv) bitwise_not(roi, roi); } - drawRectangle(&image, Rect(w[0]*image.cols, w[1]*image.rows, w[2]*image.cols, w[3]*image.rows)); + drawRectangle(&image, Rect(cvRound(w[0]*image.cols), cvRound(w[1]*image.rows), + cvRound(w[2]*image.cols), cvRound(w[3]*image.rows))); imshow("Win", image); waitKey(100); @@ -174,5 +177,4 @@ int main(int argc, char** argv) fclose(f); return 0; - } diff --git a/samples/cpp/latentsvm_multidetect.cpp b/samples/cpp/latentsvm_multidetect.cpp index 9f9c330..07af7c9 100644 --- a/samples/cpp/latentsvm_multidetect.cpp +++ b/samples/cpp/latentsvm_multidetect.cpp @@ -107,13 +107,13 @@ int main(int argc, char* argv[]) help(); string images_folder, models_folder; - float overlapThreshold = 0.2; + float overlapThreshold = 0.2f; int numThreads = -1; if( argc > 2 ) { images_folder = argv[1]; models_folder = argv[2]; - if( argc > 3 ) overlapThreshold = atof(argv[3]); + if( argc > 3 ) overlapThreshold = (float)atof(argv[3]); if( overlapThreshold < 0 || overlapThreshold > 1) { cout << "overlapThreshold must be in interval (0,1)." << endl; @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) imshow( "result", image ); - while(1) + for(;;) { int c = waitKey(); if( (char)c == 'n') diff --git a/samples/cpp/linemod.cpp b/samples/cpp/linemod.cpp index d563a62..8677717 100644 --- a/samples/cpp/linemod.cpp +++ b/samples/cpp/linemod.cpp @@ -48,7 +48,7 @@ public: } private: - static void cv_on_mouse(int a_event, int a_x, int a_y, int a_flags, void * a_params) + static void cv_on_mouse(int a_event, int a_x, int a_y, int, void *) { m_event = a_event; m_x = a_x; @@ -186,7 +186,7 @@ int main(int argc, char * argv[]) std::copy(ids.begin(), ids.end(), std::ostream_iterator(std::cout, "\n")); } } - int num_modalities = detector->getModalities().size(); + int num_modalities = (int)detector->getModalities().size(); // Open Kinect sensor cv::VideoCapture capture( CV_CAP_OPENNI ); @@ -201,7 +201,7 @@ int main(int argc, char * argv[]) // Main loop cv::Mat color, depth; - while (true) + for(;;) { // Capture next color/depth pair capture.grab(); @@ -262,7 +262,7 @@ int main(int argc, char * argv[]) std::vector class_ids; std::vector quantized_images; match_timer.start(); - detector->match(sources, matching_threshold, matches, class_ids, quantized_images); + detector->match(sources, (float)matching_threshold, matches, class_ids, quantized_images); match_timer.stop(); int classes_visited = 0; @@ -331,6 +331,9 @@ int main(int argc, char * argv[]) cv::FileStorage fs; char key = (char)cvWaitKey(10); + if( key == 'q' ) + break; + switch (key) { case 'h': @@ -366,8 +369,8 @@ int main(int argc, char * argv[]) writeLinemod(detector, filename); printf("Wrote detector and templates to %s\n", filename.c_str()); break; - case 'q': - return 0; + default: + ; } } return 0; @@ -403,8 +406,8 @@ void filterPlane(IplImage * ap_depth, std::vector & a_masks, std::ve for (int l_i = 0; l_i < (int)a_chain.size(); ++l_i) { - float x_diff = a_chain[(l_i + 1) % a_chain.size()].x - a_chain[l_i].x; - float y_diff = a_chain[(l_i + 1) % a_chain.size()].y - a_chain[l_i].y; + float x_diff = (float)(a_chain[(l_i + 1) % a_chain.size()].x - a_chain[l_i].x); + float y_diff = (float)(a_chain[(l_i + 1) % a_chain.size()].y - a_chain[l_i].y); lp_seg_length[l_i] = sqrt(x_diff*x_diff + y_diff*y_diff); l_chain_length += lp_seg_length[l_i]; } @@ -412,7 +415,7 @@ void filterPlane(IplImage * ap_depth, std::vector & a_masks, std::ve { if (lp_seg_length[l_i] > 0) { - int l_cur_num = l_num_cost_pts * lp_seg_length[l_i] / l_chain_length; + int l_cur_num = cvRound(l_num_cost_pts * lp_seg_length[l_i] / l_chain_length); float l_cur_len = lp_seg_length[l_i] / l_cur_num; for (int l_j = 0; l_j < l_cur_num; ++l_j) @@ -421,8 +424,8 @@ void filterPlane(IplImage * ap_depth, std::vector & a_masks, std::ve CvPoint l_pts; - l_pts.x = l_ratio * (a_chain[(l_i + 1) % a_chain.size()].x - a_chain[l_i].x) + a_chain[l_i].x; - l_pts.y = l_ratio * (a_chain[(l_i + 1) % a_chain.size()].y - a_chain[l_i].y) + a_chain[l_i].y; + l_pts.x = cvRound(l_ratio * (a_chain[(l_i + 1) % a_chain.size()].x - a_chain[l_i].x) + a_chain[l_i].x); + l_pts.y = cvRound(l_ratio * (a_chain[(l_i + 1) % a_chain.size()].y - a_chain[l_i].y) + a_chain[l_i].y); l_chain_vector.push_back(l_pts); } @@ -441,16 +444,16 @@ void filterPlane(IplImage * ap_depth, std::vector & a_masks, std::ve reprojectPoints(lp_src_3Dpts, lp_src_3Dpts, f); - CvMat * lp_pts = cvCreateMat(l_chain_vector.size(), 4, CV_32F); + CvMat * lp_pts = cvCreateMat((int)l_chain_vector.size(), 4, CV_32F); CvMat * lp_v = cvCreateMat(4, 4, CV_32F); CvMat * lp_w = cvCreateMat(4, 1, CV_32F); for (int l_i = 0; l_i < (int)l_chain_vector.size(); ++l_i) { - CV_MAT_ELEM(*lp_pts, float, l_i, 0) = lp_src_3Dpts[l_i].x; - CV_MAT_ELEM(*lp_pts, float, l_i, 1) = lp_src_3Dpts[l_i].y; - CV_MAT_ELEM(*lp_pts, float, l_i, 2) = lp_src_3Dpts[l_i].z; - CV_MAT_ELEM(*lp_pts, float, l_i, 3) = 1.0; + CV_MAT_ELEM(*lp_pts, float, l_i, 0) = (float)lp_src_3Dpts[l_i].x; + CV_MAT_ELEM(*lp_pts, float, l_i, 1) = (float)lp_src_3Dpts[l_i].y; + CV_MAT_ELEM(*lp_pts, float, l_i, 2) = (float)lp_src_3Dpts[l_i].z; + CV_MAT_ELEM(*lp_pts, float, l_i, 3) = 1.0f; } cvSVD(lp_pts, lp_w, 0, lp_v); @@ -493,7 +496,7 @@ void filterPlane(IplImage * ap_depth, std::vector & a_masks, std::ve } int l_w = l_maxx - l_minx + 1; int l_h = l_maxy - l_miny + 1; - int l_nn = a_chain.size(); + int l_nn = (int)a_chain.size(); CvPoint * lp_chain = new CvPoint[l_nn]; @@ -528,7 +531,7 @@ void filterPlane(IplImage * ap_depth, std::vector & a_masks, std::ve { for (int l_c = 0; l_c < l_w; ++l_c) { - float l_dist = l_n[0] * lp_dst_3Dpts[l_ind].x + l_n[1] * lp_dst_3Dpts[l_ind].y + lp_dst_3Dpts[l_ind].z * l_n[2] + l_n[3]; + float l_dist = (float)(l_n[0] * lp_dst_3Dpts[l_ind].x + l_n[1] * lp_dst_3Dpts[l_ind].y + lp_dst_3Dpts[l_ind].z * l_n[2] + l_n[3]); ++l_ind; @@ -538,8 +541,8 @@ void filterPlane(IplImage * ap_depth, std::vector & a_masks, std::ve { for (int l_p = 0; l_p < (int)a_masks.size(); ++l_p) { - int l_col = (l_c + l_minx) / (l_p + 1.0); - int l_row = (l_r + l_miny) / (l_p + 1.0); + int l_col = cvRound((l_c + l_minx) / (l_p + 1.0)); + int l_row = cvRound((l_r + l_miny) / (l_p + 1.0)); CV_IMAGE_ELEM(a_masks[l_p], unsigned char, l_row, l_col) = 0; } @@ -548,8 +551,8 @@ void filterPlane(IplImage * ap_depth, std::vector & a_masks, std::ve { for (int l_p = 0; l_p < (int)a_masks.size(); ++l_p) { - int l_col = (l_c + l_minx) / (l_p + 1.0); - int l_row = (l_r + l_miny) / (l_p + 1.0); + int l_col = cvRound((l_c + l_minx) / (l_p + 1.0)); + int l_row = cvRound((l_r + l_miny) / (l_p + 1.0)); CV_IMAGE_ELEM(a_masks[l_p], unsigned char, l_row, l_col) = 255; } @@ -669,7 +672,7 @@ void templateConvexHull(const std::vector& templates, cv::convexHull(points, hull); dst = cv::Mat::zeros(size, CV_8U); - const int hull_count = hull.size(); + const int hull_count = (int)hull.size(); const cv::Point* hull_pts = &hull[0]; cv::fillPoly(dst, &hull_pts, &hull_count, 1, cv::Scalar(255)); } diff --git a/samples/cpp/matching_to_many_images.cpp b/samples/cpp/matching_to_many_images.cpp index 7c6e3b9..ce77637 100644 --- a/samples/cpp/matching_to_many_images.cpp +++ b/samples/cpp/matching_to_many_images.cpp @@ -192,7 +192,7 @@ void saveResultImages( const Mat& queryImage, const vector& queryKeypo { if( !trainImages[i].empty() ) { - maskMatchesByTrainImgIdx( matches, i, mask ); + maskMatchesByTrainImgIdx( matches, (int)i, mask ); drawMatches( queryImage, queryKeypoints, trainImages[i], trainKeypoints[i], matches, drawImg, Scalar(255, 0, 0), Scalar(0, 255, 255), mask ); string filename = resultDir + "/res_" + trainImagesNames[i]; diff --git a/samples/cpp/openni_capture.cpp b/samples/cpp/openni_capture.cpp index 1e72e13..2d1aac1 100644 --- a/samples/cpp/openni_capture.cpp +++ b/samples/cpp/openni_capture.cpp @@ -184,7 +184,7 @@ int main( int argc, char* argv[] ) return -1; } - bool modeRes; + bool modeRes=false; switch ( imageMode ) { case 0: diff --git a/samples/cpp/peopledetect.cpp b/samples/cpp/peopledetect.cpp index 7adc613..32d6e12 100644 --- a/samples/cpp/peopledetect.cpp +++ b/samples/cpp/peopledetect.cpp @@ -60,7 +60,7 @@ int main(int argc, char** argv) // ++filename; if(filename[0] == '#') continue; - int l = strlen(filename); + int l = (int)strlen(filename); while(l > 0 && isspace(filename[l-1])) --l; filename[l] = '\0'; diff --git a/samples/cpp/phase_corr.cpp b/samples/cpp/phase_corr.cpp index 649ed8d..f9088a0 100644 --- a/samples/cpp/phase_corr.cpp +++ b/samples/cpp/phase_corr.cpp @@ -4,7 +4,7 @@ using namespace cv; -int main(int argc, char* argv[]) +int main(int, char* []) { VideoCapture video(0); Mat frame, curr, prev, curr64f, prev64f, hann; diff --git a/samples/cpp/point_cloud.cpp b/samples/cpp/point_cloud.cpp index 694751f..5cfcf79 100644 --- a/samples/cpp/point_cloud.cpp +++ b/samples/cpp/point_cloud.cpp @@ -196,7 +196,7 @@ int main(int argc, const char* argv[]) setMouseCallback(windowName, mouseCallback, &renderer); setOpenGlDrawCallback(windowName, openGlDrawCallback, &renderer); - while (true) + for(;;) { int key = waitKey(10); diff --git a/samples/cpp/points_classifier.cpp b/samples/cpp/points_classifier.cpp index 47ab938..ecb5a5f 100644 --- a/samples/cpp/points_classifier.cpp +++ b/samples/cpp/points_classifier.cpp @@ -43,7 +43,7 @@ void on_mouse( int event, int x, int y, int /*flags*/, void* ) return; trainedPoints.push_back( Point(x,y) ); - trainedPointsMarkers.push_back( classColors.size()-1 ); + trainedPointsMarkers.push_back( (int)(classColors.size()-1) ); updateFlag = true; } else if( event == CV_EVENT_RBUTTONUP ) diff --git a/samples/cpp/rgbdodometry.cpp b/samples/cpp/rgbdodometry.cpp index 16a0078..25bf115 100644 --- a/samples/cpp/rgbdodometry.cpp +++ b/samples/cpp/rgbdodometry.cpp @@ -101,21 +101,21 @@ int main(int argc, char** argv) return -1; } - int transformationType = TransformationType::RIGID_BODY_MOTION; + int transformationType = RIGID_BODY_MOTION; if( argc == 6 ) { string ttype = argv[5]; if( ttype == "-rbm" ) { - transformationType = TransformationType::RIGID_BODY_MOTION; + transformationType = RIGID_BODY_MOTION; } else if ( ttype == "-r") { - transformationType = TransformationType::ROTATION; + transformationType = ROTATION; } else if ( ttype == "-t") { - transformationType = TransformationType::TRANSLATION; + transformationType = TRANSLATION; } else { @@ -145,9 +145,9 @@ int main(int argc, char** argv) minGradMagnitudes[2] = 3; minGradMagnitudes[3] = 1; - const float minDepth = 0; //in meters - const float maxDepth = 3; //in meters - const float maxDepthDiff = 0.07; //in meters + const float minDepth = 0.f; //in meters + const float maxDepth = 3.f; //in meters + const float maxDepthDiff = 0.07f; //in meters tm.start(); bool isFound = cv::RGBDOdometry( Rt, Mat(), diff --git a/samples/cpp/select3dobj.cpp b/samples/cpp/select3dobj.cpp index b2d7f84..94ade9b 100644 --- a/samples/cpp/select3dobj.cpp +++ b/samples/cpp/select3dobj.cpp @@ -173,13 +173,13 @@ static Rect extract3DBox(const Mat& frame, Mat& shownFrame, Mat& selectedObjFram vector hull; convexHull(Mat_(Mat(imgpt)), hull); Mat selectedObjMask = Mat::zeros(frame.size(), CV_8U); - fillConvexPoly(selectedObjMask, &hull[0], hull.size(), Scalar::all(255), 8, 0); + fillConvexPoly(selectedObjMask, &hull[0], (int)hull.size(), Scalar::all(255), 8, 0); Rect roi = boundingRect(Mat(hull)) & Rect(Point(), frame.size()); if( runExtraSegmentation ) { selectedObjMask = Scalar::all(GC_BGD); - fillConvexPoly(selectedObjMask, &hull[0], hull.size(), Scalar::all(GC_PR_FGD), 8, 0); + fillConvexPoly(selectedObjMask, &hull[0], (int)hull.size(), Scalar::all(GC_PR_FGD), 8, 0); Mat bgdModel, fgdModel; grabCut(frame, selectedObjMask, roi, bgdModel, fgdModel, 3, GC_INIT_WITH_RECT + GC_INIT_WITH_MASK); diff --git a/samples/cpp/stitching_detailed.cpp b/samples/cpp/stitching_detailed.cpp index 609cd48..1849142 100644 --- a/samples/cpp/stitching_detailed.cpp +++ b/samples/cpp/stitching_detailed.cpp @@ -570,8 +570,9 @@ int main(int argc, char* argv[]) { Mat_ K; cameras[i].K().convertTo(K, CV_32F); - K(0,0) *= seam_work_aspect; K(0,2) *= seam_work_aspect; - K(1,1) *= seam_work_aspect; K(1,2) *= seam_work_aspect; + float swa = (float)seam_work_aspect; + K(0,0) *= swa; K(0,2) *= swa; + K(1,1) *= swa; K(1,2) *= swa; corners[i] = warper->warp(images[i], K, cameras[i].R, INTER_LINEAR, BORDER_REFLECT, images_warped[i]); sizes[i] = images_warped[i].size(); diff --git a/samples/cpp/video_dmtx.cpp b/samples/cpp/video_dmtx.cpp index 9fd34dc..946aa35 100644 --- a/samples/cpp/video_dmtx.cpp +++ b/samples/cpp/video_dmtx.cpp @@ -51,7 +51,7 @@ int process(VideoCapture& capture) { capture >> frame; if (frame.empty()) - continue; + break; cv::Mat gray; cv::cvtColor(frame,gray,CV_RGB2GRAY); findDataMatrix(gray, codes); diff --git a/samples/gpu/alpha_comp.cpp b/samples/gpu/alpha_comp.cpp index 7432af9..7adf61b 100644 --- a/samples/gpu/alpha_comp.cpp +++ b/samples/gpu/alpha_comp.cpp @@ -42,7 +42,7 @@ int main() "ALPHA_ATOP_PREMUL", "ALPHA_XOR_PREMUL", "ALPHA_PLUS_PREMUL", "ALPHA_PREMUL" }; - while (true) + for(;;) { cout << op_names[alpha_op] << endl; diff --git a/samples/gpu/brox_optical_flow.cpp b/samples/gpu/brox_optical_flow.cpp index 0e956f5..95e90e7 100644 --- a/samples/gpu/brox_optical_flow.cpp +++ b/samples/gpu/brox_optical_flow.cpp @@ -208,7 +208,7 @@ int main(int argc, const char* argv[]) imshow("Interpolated frame", frames[currentFrame]); - while (true) + for(;;) { int key = toupper(waitKey(10) & 0xff); diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index 29639e7..a49ba2a 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -1172,7 +1172,7 @@ TEST(PyrLKOpticalFlow) gpu::GpuMat d_frame1(frame1); gpu::GpuMat d_pts; - Mat pts_mat(1, pts.size(), CV_32FC2, (void*)&pts[0]); + Mat pts_mat(1, (int)pts.size(), CV_32FC2, (void*)&pts[0]); d_pts.upload(pts_mat); gpu::GpuMat d_nextPts; -- 2.7.4