From 5e2bcacba55f222eb15dd69b28b014896787593e Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Wed, 21 Mar 2012 07:35:25 +0000 Subject: [PATCH] Fixed some warnings --- .../include/opencv2/videostab/global_motion.hpp | 2 +- modules/videostab/include/opencv2/videostab/log.hpp | 2 +- modules/videostab/src/deblurring.cpp | 12 +++++++----- modules/videostab/src/global_motion.cpp | 18 +++++++++--------- modules/videostab/src/inpainting.cpp | 10 ++++++++-- modules/videostab/src/stabilizer.cpp | 6 +++--- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/modules/videostab/include/opencv2/videostab/global_motion.hpp b/modules/videostab/include/opencv2/videostab/global_motion.hpp index 773e82e..de924bb 100644 --- a/modules/videostab/include/opencv2/videostab/global_motion.hpp +++ b/modules/videostab/include/opencv2/videostab/global_motion.hpp @@ -64,7 +64,7 @@ CV_EXPORTS Mat estimateGlobalMotionLeastSquares( const std::vector &points0, const std::vector &points1, int model = AFFINE, float *rmse = 0); -CV_EXPORTS struct RansacParams +struct CV_EXPORTS RansacParams { int size; // subset size float thresh; // max error to classify as inlier diff --git a/modules/videostab/include/opencv2/videostab/log.hpp b/modules/videostab/include/opencv2/videostab/log.hpp index 474f37b..ce6fadf 100644 --- a/modules/videostab/include/opencv2/videostab/log.hpp +++ b/modules/videostab/include/opencv2/videostab/log.hpp @@ -60,7 +60,7 @@ public: class CV_EXPORTS NullLog : public ILog { public: - virtual void print(const char */*format*/, ...) {} + virtual void print(const char * /*format*/, ...) {} }; class CV_EXPORTS LogToStdout : public ILog diff --git a/modules/videostab/src/deblurring.cpp b/modules/videostab/src/deblurring.cpp index c8eccf2..4443064 100644 --- a/modules/videostab/src/deblurring.cpp +++ b/modules/videostab/src/deblurring.cpp @@ -59,13 +59,13 @@ float calcBlurriness(const Mat &frame) double normGx = norm(Gx); double normGy = norm(Gx); double sumSq = normGx*normGx + normGy*normGy; - return 1.f / (sumSq / frame.size().area() + 1e-6); + return 1.f / (sumSq / frame.size().area() + 1e-6f); } WeightingDeblurer::WeightingDeblurer() { - setSensitivity(0.1); + setSensitivity(0.1f); } @@ -102,8 +102,8 @@ void WeightingDeblurer::deblur(int idx, Mat &frame) { for (int x = 0; x < frame.cols; ++x) { - int x1 = M(0,0)*x + M(0,1)*y + M(0,2); - int y1 = M(1,0)*x + M(1,1)*y + M(1,2); + int x1 = static_cast(M(0,0)*x + M(0,1)*y + M(0,2)); + int y1 = static_cast(M(1,0)*x + M(1,1)*y + M(1,2)); if (x1 >= 0 && x1 < neighbor.cols && y1 >= 0 && y1 < neighbor.rows) { @@ -127,7 +127,9 @@ void WeightingDeblurer::deblur(int idx, Mat &frame) { float wSumInv = 1.f / wSum_(y,x); frame.at >(y,x) = Point3_( - bSum_(y,x) * wSumInv, gSum_(y,x) * wSumInv, rSum_(y,x) * wSumInv); + static_cast(bSum_(y,x)*wSumInv), + static_cast(gSum_(y,x)*wSumInv), + static_cast(rSum_(y,x)*wSumInv)); } } } diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index c8fd6b5..9c48557 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -97,7 +97,7 @@ static Mat estimateGlobMotionLeastSquaresTranslationAndScale( solve(A, b, sol, DECOMP_SVD); if (rmse) - *rmse = norm(A*sol, b, NORM_L2) / sqrt((double)npoints); + *rmse = norm(A*sol, b, NORM_L2) / sqrt(static_cast(npoints)); Mat_ M = Mat::eye(3, 3, CV_32F); M(0,0) = M(1,1) = sol(0,0); @@ -130,7 +130,7 @@ static Mat estimateGlobMotionLeastSquaresAffine( solve(A, b, sol, DECOMP_SVD); if (rmse) - *rmse = norm(A*sol, b, NORM_L2) / sqrt((double)npoints); + *rmse = norm(A*sol, b, NORM_L2) / sqrt(static_cast(npoints)); Mat_ M = Mat::eye(3, 3, CV_32F); for (int i = 0, k = 0; i < 2; ++i) @@ -314,9 +314,9 @@ Mat getMotion(int from, int to, const vector &motions) static inline int areaSign(Point2f a, Point2f b, Point2f c) { - float area = (b-a).cross(c-a); - if (area < -1e-5f) return -1; - if (area > 1e-5f) return 1; + double area = (b-a).cross(c-a); + if (area < -1e-5) return -1; + if (area > 1e-5) return 1; return 0; } @@ -378,8 +378,8 @@ Mat ensureInclusionConstraint(const Mat &M, Size size, float trimRatio) { CV_Assert(M.size() == Size(3,3) && M.type() == CV_32F); - const float w = size.width; - const float h = size.height; + const float w = static_cast(size.width); + const float h = static_cast(size.height); const float dx = floor(w * trimRatio); const float dy = floor(h * trimRatio); const float srcM[6] = @@ -414,8 +414,8 @@ float estimateOptimalTrimRatio(const Mat &M, Size size) { CV_Assert(M.size() == Size(3,3) && M.type() == CV_32F); - const float w = size.width; - const float h = size.height; + const float w = static_cast(size.width); + const float h = static_cast(size.height); Mat_ M_(M); Point2f pt[4] = {Point2f(0,0), Point2f(w,0), Point2f(w,h), Point2f(0,h)}; diff --git a/modules/videostab/src/inpainting.cpp b/modules/videostab/src/inpainting.cpp index c7452dd..76dcf79 100644 --- a/modules/videostab/src/inpainting.cpp +++ b/modules/videostab/src/inpainting.cpp @@ -175,7 +175,10 @@ void ConsistentMosaicInpainter::inpaint(int idx, Mat &frame, Mat &mask) c2 = (c2 + pixels[nh].color.y) / 2; c3 = (c3 + pixels[nh].color.z) / 2; } - frame_(y, x) = Point3_(c1, c2, c3); + frame_(y, x) = Point3_( + static_cast(c1), + static_cast(c2), + static_cast(c3)); mask_(y, x) = 255; } } @@ -379,7 +382,10 @@ public: } float wSumInv = 1.f / wSum; - frame(y,x) = Point3_(c1*wSumInv, c2*wSumInv, c3*wSumInv); + frame(y,x) = Point3_( + static_cast(c1*wSumInv), + static_cast(c2*wSumInv), + static_cast(c3*wSumInv)); mask(y,x) = 255; } diff --git a/modules/videostab/src/stabilizer.cpp b/modules/videostab/src/stabilizer.cpp index 4bdb803..ac7fd9c 100644 --- a/modules/videostab/src/stabilizer.cpp +++ b/modules/videostab/src/stabilizer.cpp @@ -54,7 +54,7 @@ Stabilizer::Stabilizer() { setFrameSource(new NullFrameSource()); setMotionEstimator(new PyrLkRobustMotionEstimator()); - setMotionFilter(new GaussianMotionFilter(15, sqrt(15.0))); + setMotionFilter(new GaussianMotionFilter(15, sqrt(15.f))); setDeblurer(new NullDeblurer()); setInpainter(new NullInpainter()); setEstimateTrimRatio(true); @@ -101,8 +101,8 @@ Mat Stabilizer::nextFrame() return Mat(); // frame source is empty const Mat &stabilizedFrame = at(curStabilizedPos_, stabilizedFrames_); - int dx = floor(trimRatio_ * stabilizedFrame.cols); - int dy = floor(trimRatio_ * stabilizedFrame.rows); + int dx = static_cast(floor(trimRatio_ * stabilizedFrame.cols)); + int dy = static_cast(floor(trimRatio_ * stabilizedFrame.rows)); return stabilizedFrame(Rect(dx, dy, stabilizedFrame.cols - 2*dx, stabilizedFrame.rows - 2*dy)); } -- 2.7.4