From f92a1aa07d16d6b57b7a77c4d75d21b823f8a6fc Mon Sep 17 00:00:00 2001 From: Rostislav Vasilikhin Date: Fri, 16 Sep 2022 18:00:00 +0200 Subject: [PATCH] trying to fix MSVC compilation double -> float warning fix warnings in the rest 3d module files extra var removed try to fix warnings --- modules/3d/src/rgbd/normal.cpp | 8 ++-- modules/3d/src/rgbd/odometry.cpp | 2 +- modules/3d/src/rgbd/odometry_functions.cpp | 5 ++- modules/calib/src/calibration.cpp | 15 ++++--- modules/calib/test/test_cameracalibration.cpp | 40 +++++++++---------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/modules/3d/src/rgbd/normal.cpp b/modules/3d/src/rgbd/normal.cpp index 69e062bfb0..9a76306b87 100644 --- a/modules/3d/src/rgbd/normal.cpp +++ b/modules/3d/src/rgbd/normal.cpp @@ -461,7 +461,7 @@ public: typedef Vec Vec3T; typedef Matx Mat33T; - LINEMOD(int _rows, int _cols, int _windowSize, const Mat& _K, float _diffThr = 50.f) : + LINEMOD(int _rows, int _cols, int _windowSize, const Mat& _K, double _diffThr = 50.0) : RgbdNormalsImpl(_rows, _cols, _windowSize, _K, RgbdNormals::RGBD_NORMALS_METHOD_LINEMOD), differenceThreshold(_diffThr) { } @@ -552,9 +552,9 @@ public: Vec3T X1_minus_X, X2_minus_X; - ContainerDepth difference_threshold(differenceThreshold); + ContainerDepth difference_threshold((ContainerDepth)differenceThreshold); //TODO: fixit, difference threshold should not depend on input type - difference_threshold *= (std::is_same::value ? 1000.f : 1.f); + difference_threshold *= (ContainerDepth)(std::is_same::value ? 1000.0 : 1.0); normals.setTo(std::numeric_limits::quiet_NaN()); for (int y = r; y < this->rows - r - 1; ++y) { @@ -609,7 +609,7 @@ public: return normals; } - float differenceThreshold; + double differenceThreshold; }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/3d/src/rgbd/odometry.cpp b/modules/3d/src/rgbd/odometry.cpp index 4cba5debc3..91a1361185 100644 --- a/modules/3d/src/rgbd/odometry.cpp +++ b/modules/3d/src/rgbd/odometry.cpp @@ -517,7 +517,7 @@ void warpFrame(InputArray depth, InputArray image, InputArray mask, if (z < oldz) { - zBuffer.at(uv) = z; + zBuffer.at(uv) = (float)z; switch (imageType) { diff --git a/modules/3d/src/rgbd/odometry_functions.cpp b/modules/3d/src/rgbd/odometry_functions.cpp index 6baea1b2bd..42ccbf0689 100644 --- a/modules/3d/src/rgbd/odometry_functions.cpp +++ b/modules/3d/src/rgbd/odometry_functions.cpp @@ -290,6 +290,7 @@ void prepareICPFrameDst(OdometryFrame& frame, OdometrySettings settings) depth.depth(), cameraMatrix, normalWinSize, + 50.f, normalMethod); TMat c0; frame.getPyramidAt(c0, OdometryFramePyramidType::PYR_CLOUD, 0); @@ -935,7 +936,7 @@ void computeCorresps(const Matx33f& _K, const Mat& rt, _corresps.create(correspCount, 1, CV_32SC4); Vec4i* corresps_ptr = _corresps.ptr(); - float* diffs_ptr; + float* diffs_ptr = nullptr; if (method == OdometryType::RGB) { _diffs.create(correspCount, 1, CV_32F); @@ -944,7 +945,7 @@ void computeCorresps(const Matx33f& _K, const Mat& rt, for (int vsrc = 0, i = 0; vsrc < corresps.rows; vsrc++) { const Vec2s* corresps_row = corresps.ptr(vsrc); - const float* diffs_row; + const float* diffs_row = nullptr; if (method == OdometryType::RGB) diffs_row = diffs.ptr(vsrc); for (int usrc = 0; usrc < corresps.cols; usrc++) diff --git a/modules/calib/src/calibration.cpp b/modules/calib/src/calibration.cpp index dc24f057eb..5c25860d82 100644 --- a/modules/calib/src/calibration.cpp +++ b/modules/calib/src/calibration.cpp @@ -433,8 +433,7 @@ static double calibrateCameraInternal( const Mat& objectPoints, if (releaseObject) JoBuf = Mat( maxPoints*2, maxPoints*3, CV_64FC1); - auto cameraCalcJErr = [matM, _m, npoints, nimages, flags, releaseObject, nparams, maxPoints, aspectRatio, NINTRINSIC, - &JeBuf, &JiBuf, &JoBuf, &errBuf, &allErrors, &perViewErr] + auto cameraCalcJErr = [&, npoints, nimages, flags, releaseObject, nparams, maxPoints, NINTRINSIC] (InputOutputArray _param, OutputArray _JtErr, OutputArray _JtJ, double& errnorm) -> bool { bool optimizeObjPoints = releaseObject; @@ -659,7 +658,7 @@ static double stereoCalibrateImpl( Matx33d A[2]; int pointsTotal = 0, maxPoints = 0, nparams; bool recomputeIntrinsics = false; - double aspectRatio[2] = {0}; + double aspectRatio[2] = {0, 0}; CV_Assert( _imagePoints1.type() == _imagePoints2.type() && _imagePoints1.depth() == _objectPoints.depth() ); @@ -675,7 +674,8 @@ static double stereoCalibrateImpl( pointsTotal += ni; } - Mat objectPoints, imagePoints[2]; + Mat objectPoints; + Mat imagePoints[2]; _objectPoints.convertTo(objectPoints, CV_64F); objectPoints = objectPoints.reshape(3, 1); @@ -895,8 +895,7 @@ static double stereoCalibrateImpl( Mat J_LRBuf( maxPoints*2, 6, CV_64F ); Mat JiBuf( maxPoints*2, NINTRINSIC, CV_64F, Scalar(0) ); - auto lmcallback = [errBuf, JeBuf, J_LRBuf, JiBuf, recomputeIntrinsics, nimages, flags, aspectRatio, &A, &dk, NINTRINSIC, - _npoints, objectPoints, imagePoints, Dist, &perViewErr] + auto lmcallback = [&, recomputeIntrinsics, nimages, flags, NINTRINSIC, _npoints] (InputOutputArray _param, OutputArray JtErr_, OutputArray JtJ_, double& errnorm) { Mat_ param_m = _param.getMat(); @@ -911,7 +910,7 @@ static double stereoCalibrateImpl( if( recomputeIntrinsics ) { - size_t idx = (nimages+1)*6; + int idx = (nimages+1)*6; if( flags & CALIB_SAME_FOCAL_LENGTH ) { @@ -949,7 +948,7 @@ static double stereoCalibrateImpl( { int ni = _npoints.at(i); - size_t idx = (i+1)*6; + int idx = (i+1)*6; om[0] = Vec3d(param_m(idx + 0), param_m(idx + 1), param_m(idx + 2)); T[0] = Vec3d(param_m(idx + 3), param_m(idx + 4), param_m(idx + 5)); diff --git a/modules/calib/test/test_cameracalibration.cpp b/modules/calib/test/test_cameracalibration.cpp index cf852a7986..62cb27e96c 100644 --- a/modules/calib/test/test_cameracalibration.cpp +++ b/modules/calib/test/test_cameracalibration.cpp @@ -2026,28 +2026,28 @@ TEST(Calib_StereoCalibrate, regression_22421) fs["desiredT"] >> desiredT; std::vector obj_points = {0, 0, 0, - 0.5, 0, 0, - 1, 0, 0, - 1.5000001, 0, 0, - 2, 0, 0, - 0, 0.5, 0, - 0.5, 0.5, 0, - 1, 0.5, 0, - 1.5000001, 0.5, 0, - 2, 0.5, 0, - 0, 1, 0, - 0.5, 1, 0, - 1, 1, 0, - 1.5000001, 1, 0, - 2, 1, 0, - 0, 1.5000001, 0, - 0.5, 1.5000001, 0, - 1, 1.5000001, 0, - 1.5000001, 1.5000001, 0, - 2, 1.5000001, 0}; + 0.5f, 0, 0, + 1.f, 0, 0, + 1.5000001f, 0, 0, + 2.0f, 0, 0, + 0, 0.5f, 0, + 0.5f, 0.5f, 0, + 1.f, 0.5, 0, + 1.5000001f, 0.5f, 0, + 2.f, 0.5f, 0, + 0, 1.f, 0, + 0.5f, 1.f, 0, + 1.f, 1.f, 0, + 1.5000001f, 1.f, 0, + 2.f, 1.f, 0, + 0, 1.5000001f, 0, + 0.5f, 1.5000001f, 0, + 1.f, 1.5000001f, 0, + 1.5000001f, 1.5000001f, 0, + 2.f, 1.5000001f, 0}; cv::Mat obj_points_mat(obj_points, true); - obj_points_mat = obj_points_mat.reshape(1, obj_points.size() / 3); + obj_points_mat = obj_points_mat.reshape(1, int(obj_points.size()) / 3); std::vector grid_points(image_points1.size(), obj_points_mat); cv::Mat R, T;