From b7560332068ce52799e727f1b102cb09f9f1c162 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 11 Apr 2012 11:11:39 +0000 Subject: [PATCH] Fixed several warnings on various platforms --- 3rdparty/libjasper/CMakeLists.txt | 4 ++++ modules/contrib/src/colormap.cpp | 5 +++-- modules/contrib/src/facerec.cpp | 4 ++-- modules/contrib/src/lda.cpp | 8 ++++---- modules/contrib/src/spinimages.cpp | 2 +- modules/core/src/dxt.cpp | 1 + modules/gpu/test/test_calib3d.cpp | 4 ++-- modules/gpu/test/test_video.cpp | 2 +- modules/python/src2/cv2.cpp | 5 +++-- modules/videostab/src/global_motion.cpp | 2 +- modules/videostab/src/stabilizer.cpp | 2 +- samples/c/contours.c | 2 +- samples/c/fback_c.c | 2 +- samples/gpu/brox_optical_flow.cpp | 1 - 14 files changed, 25 insertions(+), 19 deletions(-) diff --git a/3rdparty/libjasper/CMakeLists.txt b/3rdparty/libjasper/CMakeLists.txt index ea99f57..61bb6a8 100644 --- a/3rdparty/libjasper/CMakeLists.txt +++ b/3rdparty/libjasper/CMakeLists.txt @@ -29,6 +29,10 @@ if(MSVC) add_definitions(-DJAS_WIN_MSVC_BUILD) endif() +if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-uninitialized") +endif() + if(UNIX) if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") diff --git a/modules/contrib/src/colormap.cpp b/modules/contrib/src/colormap.cpp index 5eeb9bb..c0081c1 100644 --- a/modules/contrib/src/colormap.cpp +++ b/modules/contrib/src/colormap.cpp @@ -47,7 +47,7 @@ static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, Output Mat dst = _dst.getMat(); for(size_t idx = 0; idx < indices.size(); idx++) { Mat originalRow = src.row(indices[idx]); - Mat sortedRow = dst.row(idx); + Mat sortedRow = dst.row((int)idx); originalRow.copyTo(sortedRow); } } @@ -127,8 +127,9 @@ static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi) case CV_32SC1: return interp1_(x,Y,xi); break; case CV_32FC1: return interp1_(x,Y,xi); break; case CV_64FC1: return interp1_(x,Y,xi); break; - default: CV_Error(CV_StsUnsupportedFormat, ""); return Mat(); + default: CV_Error(CV_StsUnsupportedFormat, ""); break; } + return Mat(); } namespace colormap diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index 13a4af4..987e021 100644 --- a/modules/contrib/src/facerec.cpp +++ b/modules/contrib/src/facerec.cpp @@ -384,7 +384,7 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) { if(labels.size() != (size_t)N) CV_Error(CV_StsUnsupportedFormat, "Labels must be given as integer (CV_32SC1)."); // compute the Fisherfaces - int C = remove_dups(labels).size(); // number of unique classes + int C = (int)remove_dups(labels).size(); // number of unique classes // clip number of components to be a valid number if((_num_components <= 0) || (_num_components > (C-1))) _num_components = (C-1); @@ -549,7 +549,7 @@ histc_(const Mat& src, int minVal=0, int maxVal=255, bool normed=false) calcHist(&src, 1, 0, Mat(), result, 1, &histSize, &histRange, true, false); // normalize if(normed) { - result /= src.total(); + result /= (int)src.total(); } return result.reshape(1,1); } diff --git a/modules/contrib/src/lda.cpp b/modules/contrib/src/lda.cpp index 44eb493..f37346f 100644 --- a/modules/contrib/src/lda.cpp +++ b/modules/contrib/src/lda.cpp @@ -62,7 +62,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double if(n == 0) return Mat(); // dimensionality of samples - int d = src.getMat(0).total(); + int d = (int)src.getMat(0).total(); // create data matrix Mat data(n, d, rtype); // copy data @@ -82,7 +82,7 @@ void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArra Mat dst = _dst.getMat(); for(size_t idx = 0; idx < indices.size(); idx++) { Mat originalCol = src.col(indices[idx]); - Mat sortedCol = dst.col(idx); + Mat sortedCol = dst.col((int)idx); originalCol.copyTo(sortedCol); } } @@ -947,14 +947,14 @@ void LDA::lda(InputArray _src, InputArray _lbls) { vector num2label = remove_dups(labels); map label2num; for (size_t i = 0; i < num2label.size(); i++) - label2num[num2label[i]] = i; + label2num[num2label[i]] = (int)i; for (size_t i = 0; i < labels.size(); i++) mapped_labels[i] = label2num[labels[i]]; // get sample size, dimension int N = data.rows; int D = data.cols; // number of unique labels - int C = num2label.size(); + int C = (int)num2label.size(); // throw error if less labels, than samples if (labels.size() != (size_t)N) CV_Error(CV_StsBadArg, "Error: The number of samples must equal the number of labels."); diff --git a/modules/contrib/src/spinimages.cpp b/modules/contrib/src/spinimages.cpp index 50c7cd7..88de109 100644 --- a/modules/contrib/src/spinimages.cpp +++ b/modules/contrib/src/spinimages.cpp @@ -1171,7 +1171,7 @@ private: break; std::transform(left.begin(), left.end(), buf_beg, WgcHelper(group, groupingMat)); - int minInd = min_element(buf_beg, buf_beg + left_size) - buf_beg; + size_t minInd = min_element(buf_beg, buf_beg + left_size) - buf_beg; if (buf[minInd] < model.T_GroupingCorespondances) /* can add corespondance to group */ { diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index e08fc98..80ed8cd 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -47,6 +47,7 @@ namespace cv // On Win64 optimized versions of DFT and DCT fail the tests (fixed in VS2010) #if defined _MSC_VER && !defined CV_ICC && defined _M_X64 && _MSC_VER < 1600 #pragma optimize("", off) +#pragma warning( disable : 4748 ) #endif /****************************************************************************************\ diff --git a/modules/gpu/test/test_calib3d.cpp b/modules/gpu/test/test_calib3d.cpp index 0b6f845..bdc043f 100644 --- a/modules/gpu/test/test_calib3d.cpp +++ b/modules/gpu/test/test_calib3d.cpp @@ -249,7 +249,7 @@ TEST_P(ProjectPoints, Accuracy) for (size_t i = 0; i < dst_gold.size(); ++i) { - cv::Point2f res = h_dst.at(0, i); + cv::Point2f res = h_dst.at(0, (int)i); cv::Point2f res_gold = dst_gold[i]; ASSERT_LE(cv::norm(res_gold - res) / cv::norm(res_gold), 1e-3f); @@ -291,7 +291,7 @@ TEST_P(SolvePnPRansac, Accuracy) cv::Mat rvec, tvec; std::vector inliers; - cv::gpu::solvePnPRansac(object, cv::Mat(1, image_vec.size(), CV_32FC2, &image_vec[0]), + cv::gpu::solvePnPRansac(object, cv::Mat(1, (int)image_vec.size(), CV_32FC2, &image_vec[0]), camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), rvec, tvec, false, 200, 2.f, 100, &inliers); diff --git a/modules/gpu/test/test_video.cpp b/modules/gpu/test/test_video.cpp index aa1a4a0..7fe0b27 100644 --- a/modules/gpu/test/test_video.cpp +++ b/modules/gpu/test/test_video.cpp @@ -244,7 +244,7 @@ TEST_P(PyrLKOpticalFlow, Sparse) cv::goodFeaturesToTrack(gray_frame, pts, 1000, 0.01, 0.0); cv::gpu::GpuMat d_pts; - cv::Mat pts_mat(1, pts.size(), CV_32FC2, (void*)&pts[0]); + cv::Mat pts_mat(1, (int)pts.size(), CV_32FC2, (void*)&pts[0]); d_pts.upload(pts_mat); cv::gpu::PyrLKOpticalFlow pyrLK; diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 7d15f5e..c84d3c7 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -376,8 +376,9 @@ static bool pyopencv_to(PyObject* obj, uchar& value, const char* name = "(ivalue); + return ivalue != -1 || !PyErr_Occurred(); } static PyObject* pyopencv_from(double value) diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index c522a76..56484fa 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -353,7 +353,7 @@ Mat getMotion(int from, int to, const Mat *motions, int size) Mat getMotion(int from, int to, const vector &motions) { - return getMotion(from, to, &motions[0], motions.size()); + return getMotion(from, to, &motions[0], (int)motions.size()); } } // namespace videostab diff --git a/modules/videostab/src/stabilizer.cpp b/modules/videostab/src/stabilizer.cpp index 93868c2..d97b617 100644 --- a/modules/videostab/src/stabilizer.cpp +++ b/modules/videostab/src/stabilizer.cpp @@ -258,7 +258,7 @@ void OnePassStabilizer::estimateMotion() void OnePassStabilizer::stabilizeFrame() { - Mat stabilizationMotion = motionFilter_->stabilize(curStabilizedPos_, &motions_[0], motions_.size()); + Mat stabilizationMotion = motionFilter_->stabilize(curStabilizedPos_, &motions_[0], (int)motions_.size()); StabilizerBase::stabilizeFrame(stabilizationMotion); } diff --git a/samples/c/contours.c b/samples/c/contours.c index 8ca3448..d777408 100644 --- a/samples/c/contours.c +++ b/samples/c/contours.c @@ -49,7 +49,7 @@ static void findCComp( IplImage* img ) } -int main( int argc, char** argv ) +int main() { int i, j; CvMemStorage* storage = cvCreateMemStorage(0); diff --git a/samples/c/fback_c.c b/samples/c/fback_c.c index fb581d1..7515bcc 100644 --- a/samples/c/fback_c.c +++ b/samples/c/fback_c.c @@ -24,7 +24,7 @@ void drawOptFlowMap(const CvMat* flow, CvMat* cflowmap, int step, } } -int main(int argc, char** argv) +int main() { CvCapture* capture = cvCreateCameraCapture(0); CvMat* prevgray = 0, *gray = 0, *flow = 0, *cflow = 0; diff --git a/samples/gpu/brox_optical_flow.cpp b/samples/gpu/brox_optical_flow.cpp index 95e90e7..b610411 100644 --- a/samples/gpu/brox_optical_flow.cpp +++ b/samples/gpu/brox_optical_flow.cpp @@ -215,7 +215,6 @@ int main(int argc, const char* argv[]) switch (key) { case 27: - return 0; break; case 'A': -- 2.7.4