From 632b53667ef481b892b084016977319046e15870 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Mon, 13 May 2024 23:01:19 +0200 Subject: [PATCH] More fixes since some constructors are explicit --- ...oSimu3D_cMcd_CamVelocityWithoutVpServo.cpp | 4 +- modules/core/test/math/testColVector.cpp | 6 +- modules/core/test/math/testMathUtils.cpp | 18 +++--- modules/core/test/math/testRotation.cpp | 4 +- modules/core/test/math/testRowVector.cpp | 6 +- .../apriltag-with-dataset/testAprilTag.cpp | 59 ++++++++++--------- 6 files changed, 50 insertions(+), 47 deletions(-) diff --git a/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp b/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp index b68df9d2ee..b855f56441 100644 --- a/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp +++ b/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp @@ -28,7 +28,7 @@ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * Description: + * Description * Simulation of a 3D visual servoing. * *****************************************************************************/ @@ -267,7 +267,7 @@ int main(int argc, const char **argv) // Compute the camera translational velocity vpColVector v(3); - v = lambda * (I - vpColVector::skew(tu_cRcd)) * ctcd; + v = lambda * (I - vpColVector::skew(vpColVector(tu_cRcd))) * ctcd; // Compute the camera rotational velocity vpColVector w(3); w = lambda * tu_cRcd; diff --git a/modules/core/test/math/testColVector.cpp b/modules/core/test/math/testColVector.cpp index b2674490ec..b6eac7a01b 100644 --- a/modules/core/test/math/testColVector.cpp +++ b/modules/core/test/math/testColVector.cpp @@ -147,7 +147,7 @@ int main() M[i][0] = i; bench[i] = i; } - if (test("M", M, bench) == false) + if (test("M", vpColVector(M), bench) == false) return EXIT_FAILURE; vpColVector v; v = M; @@ -159,7 +159,7 @@ int main() vpColVector z1(bench); if (test("z1", z1, bench) == false) return EXIT_FAILURE; - vpColVector z2 = bench; + vpColVector z2 = vpColVector(bench); if (test("z2", z2, bench) == false) return EXIT_FAILURE; } @@ -191,7 +191,7 @@ int main() vpColVector y1(bench2); if (test("y1", y1, bench1) == false) return EXIT_FAILURE; - vpColVector y2 = bench2; + vpColVector y2 = vpColVector(bench2); if (test("y2", y2, bench1) == false) return EXIT_FAILURE; } diff --git a/modules/core/test/math/testMathUtils.cpp b/modules/core/test/math/testMathUtils.cpp index a847fb569a..0073d8a6f2 100644 --- a/modules/core/test/math/testMathUtils.cpp +++ b/modules/core/test/math/testMathUtils.cpp @@ -74,7 +74,7 @@ TEST_CASE("Lon-Lat generator", "[math_lonlat]") SECTION("NED") { std::vector ecef_M_ned_vec = - vpMath::getLocalTangentPlaneTransformations(lonlatVec, radius, vpMath::ned2ecef); + vpMath::getLocalTangentPlaneTransformations(lonlatVec, radius, vpMath::ned2ecef); for (const auto &ecef_M_ned : ecef_M_ned_vec) { #ifdef VERBOSE std::cout << "Lon-Lat ecef_M_ned:\n" << ecef_M_ned << std::endl; @@ -108,7 +108,7 @@ TEST_CASE("Lon-Lat generator", "[math_lonlat]") SECTION("ENU") { std::vector ecef_M_enu_vec = - vpMath::getLocalTangentPlaneTransformations(lonlatVec, radius, vpMath::enu2ecef); + vpMath::getLocalTangentPlaneTransformations(lonlatVec, radius, vpMath::enu2ecef); for (const auto &ecef_M_enu : ecef_M_enu_vec) { #ifdef VERBOSE std::cout << "Lon-Lat ecef_M_enu:\n" << ecef_M_enu << std::endl; @@ -147,7 +147,7 @@ TEST_CASE("Equidistributed sphere point", "[math_equi_sphere_pts]") SECTION("NED") { std::vector ecef_M_ned_vec = - vpMath::getLocalTangentPlaneTransformations(lonlatVec, radius, vpMath::ned2ecef); + vpMath::getLocalTangentPlaneTransformations(lonlatVec, radius, vpMath::ned2ecef); CHECK(!ecef_M_ned_vec.empty()); for (const auto &ecef_M_ned : ecef_M_ned_vec) { #ifdef VERBOSE @@ -182,7 +182,7 @@ TEST_CASE("Equidistributed sphere point", "[math_equi_sphere_pts]") SECTION("ENU") { std::vector ecef_M_enu_vec = - vpMath::getLocalTangentPlaneTransformations(lonlatVec, radius, vpMath::enu2ecef); + vpMath::getLocalTangentPlaneTransformations(lonlatVec, radius, vpMath::enu2ecef); CHECK(!ecef_M_enu_vec.empty()); for (const auto &ecef_M_enu : ecef_M_enu_vec) { #ifdef VERBOSE @@ -216,7 +216,7 @@ TEST_CASE("Equidistributed sphere point", "[math_equi_sphere_pts]") TEST_CASE("Look-at", "[math_look_at]") { // Set camera to an arbitrary pose (only translation) - vpColVector from_blender = {8.867762565612793, -1.1965436935424805, 2.1211400032043457}; + vpColVector from_blender = { 8.867762565612793, -1.1965436935424805, 2.1211400032043457 }; // Transformation from OpenGL to Blender frame vpHomogeneousMatrix blender_M_gl; blender_M_gl[0][0] = 0; @@ -229,9 +229,9 @@ TEST_CASE("Look-at", "[math_look_at]") // From is the current camera pose expressed in the OpenGL coordinate system vpColVector from = (blender_M_gl.getRotationMatrix().t() * from_blender); // To is the desired point toward the camera must look - vpColVector to = {0, 0, 0}; + vpColVector to = { 0, 0, 0 }; // Up is an arbitrary vector - vpColVector up = {0, 1, 0}; + vpColVector up = { 0, 1, 0 }; // Compute the look-at transformation vpHomogeneousMatrix gl_M_cam = vpMath::lookAt(from, to, up); @@ -246,10 +246,10 @@ TEST_CASE("Look-at", "[math_look_at]") std::cout << "\nbl_M_cv:\n" << bl_M_cv << std::endl; // Ground truth using Blender look-at - vpHomogeneousMatrix bl_M_cv_gt = {0.13372008502483368, 0.22858507931232452, -0.9642965197563171, + vpHomogeneousMatrix bl_M_cv_gt = vpHomogeneousMatrix({ 0.13372008502483368, 0.22858507931232452, -0.9642965197563171, 8.867762565612793, 0.9910191297531128, -0.030843468382954597, 0.13011434674263, -1.1965436935424805, -5.4016709327697754e-08, - -0.9730352163314819, -0.23065657913684845, 2.121140241622925}; + -0.9730352163314819, -0.23065657913684845, 2.121140241622925 }); std::cout << "\nbl_M_cv_gt:\n" << bl_M_cv_gt << std::endl; const double tolerance = 1e-6; diff --git a/modules/core/test/math/testRotation.cpp b/modules/core/test/math/testRotation.cpp index 33ac48064e..d8b01c265e 100644 --- a/modules/core/test/math/testRotation.cpp +++ b/modules/core/test/math/testRotation.cpp @@ -373,7 +373,7 @@ TEST_CASE("Common rotation operations", "[rotation]") std::cout << "From vpRotationMatrix to vpRzyzVector " << std::endl; vpRzyzVector rzyz_final; rzyz_final.buildFrom(R); - CHECK(test("rzyz", rzyz_final, rzyz)); + CHECK(test("rzyz", rzyz_final, vpColVector(rzyz))); std::cout << rzyz_final << std::endl; } SECTION("Conversion from and to rzyx vector") @@ -388,7 +388,7 @@ TEST_CASE("Common rotation operations", "[rotation]") std::cout << "From vpRotationMatrix to vpRzyxVector " << std::endl; vpRzyxVector rzyx_final; rzyx_final.buildFrom(R); - bool ret = test("rzyx", rzyx_final, rzyx); + bool ret = test("rzyx", rzyx_final, vpColVector(rzyx)); if (ret == false) { // Euler angle representation is not unique std::cout << "Rzyx vector differ. Test rotation matrix..." << std::endl; diff --git a/modules/core/test/math/testRowVector.cpp b/modules/core/test/math/testRowVector.cpp index 886c881e8e..20731459c6 100644 --- a/modules/core/test/math/testRowVector.cpp +++ b/modules/core/test/math/testRowVector.cpp @@ -125,7 +125,7 @@ int main() M[0][i] = i; bench[i] = i; } - if (test("M", M, bench) == false) + if (test("M", vpRowVector(M), bench) == false) return err; vpRowVector v; v = M; @@ -137,7 +137,7 @@ int main() vpRowVector z1(bench); if (test("z1", z1, bench) == false) return err; - vpRowVector z2 = bench; + vpRowVector z2 = vpRowVector(bench); if (test("z2", z2, bench) == false) return err; } @@ -168,7 +168,7 @@ int main() vpRowVector y1(bench2); if (test("y1", y1, bench1) == false) return err; - vpRowVector y2 = bench2; + vpRowVector y2 = vpRowVector(bench2); if (test("y2", y2, bench1) == false) return err; } diff --git a/modules/detection/test/apriltag-with-dataset/testAprilTag.cpp b/modules/detection/test/apriltag-with-dataset/testAprilTag.cpp index 829fb42945..286d54e63e 100644 --- a/modules/detection/test/apriltag-with-dataset/testAprilTag.cpp +++ b/modules/detection/test/apriltag-with-dataset/testAprilTag.cpp @@ -54,11 +54,12 @@ #include namespace { -struct TagGroundTruth { +struct TagGroundTruth +{ std::string m_message; std::vector m_corners; - TagGroundTruth(const std::string &msg, const std::vector &c) : m_message(msg), m_corners(c) {} + TagGroundTruth(const std::string &msg, const std::vector &c) : m_message(msg), m_corners(c) { } bool operator==(const TagGroundTruth &b) const { @@ -89,7 +90,8 @@ struct TagGroundTruth { const vpImagePoint &b = c[i]; error += (a.get_i() - b.get_i()) * (a.get_i() - b.get_i()) + (a.get_j() - b.get_j()) * (a.get_j() - b.get_j()); } - } else { + } + else { return -1; } @@ -109,7 +111,8 @@ std::ostream &operator<<(std::ostream &os, TagGroundTruth &t) } #endif -struct FailedTestCase { +struct FailedTestCase +{ vpDetectorAprilTag::vpAprilTagFamily m_family; vpDetectorAprilTag::vpPoseEstimationMethod m_method; int m_tagId; @@ -117,8 +120,7 @@ struct FailedTestCase { FailedTestCase(const vpDetectorAprilTag::vpAprilTagFamily &family, const vpDetectorAprilTag::vpPoseEstimationMethod &method, int tagId) : m_family(family), m_method(method), m_tagId(tagId) - { - } + { } bool operator==(const FailedTestCase &b) const { @@ -195,7 +197,7 @@ TEST_CASE("Apriltag pose estimation test", "[apriltag_pose_estimation_test]") std::vector ignoreTests = { FailedTestCase(vpDetectorAprilTag::TAG_STANDARD41h12, vpDetectorAprilTag::LAGRANGE_VIRTUAL_VS, 3), FailedTestCase(vpDetectorAprilTag::TAG_STANDARD41h12, vpDetectorAprilTag::LAGRANGE_VIRTUAL_VS, 4), - FailedTestCase(vpDetectorAprilTag::TAG_CIRCLE21h7, vpDetectorAprilTag::LAGRANGE_VIRTUAL_VS, 3)}; + FailedTestCase(vpDetectorAprilTag::TAG_CIRCLE21h7, vpDetectorAprilTag::LAGRANGE_VIRTUAL_VS, 3) }; vpCameraParameters cam; cam.initPersProjWithoutDistortion(700.0, 700.0, 320.0, 240.0); @@ -203,8 +205,8 @@ TEST_CASE("Apriltag pose estimation test", "[apriltag_pose_estimation_test]") std::map groundTruthPoses; for (size_t i = 0; i < nbTags; i++) { std::string filename = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), std::string("AprilTag/benchmark/640x480/cMo_") + - std::to_string(i) + std::string(".txt")); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), std::string("AprilTag/benchmark/640x480/cMo_") + + std::to_string(i) + std::string(".txt")); std::ifstream file(filename); groundTruthPoses[static_cast(i)].load(file); } @@ -213,8 +215,8 @@ TEST_CASE("Apriltag pose estimation test", "[apriltag_pose_estimation_test]") auto family = kv.first; std::cout << "\nApriltag family: " << family << std::endl; std::string filename = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), - std::string("AprilTag/benchmark/640x480/") + kv.second + std::string("_640x480.png")); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), + std::string("AprilTag/benchmark/640x480/") + kv.second + std::string("_640x480.png")); const double tagSize = tagSize_ * tagSizeScales[family]; REQUIRE(vpIoTools::checkFilename(filename)); @@ -260,12 +262,12 @@ TEST_CASE("Apriltag pose estimation test", "[apriltag_pose_estimation_test]") const vpHomogeneousMatrix &cMo_truth = groundTruthPoses[id]; const vpPoseVector pose_truth(cMo_truth); - vpColVector error_translation = pose.getTranslationVector() - pose_truth.getTranslationVector(); + vpColVector error_translation = vpColVector(pose.getTranslationVector() - pose_truth.getTranslationVector()); vpColVector error_thetau = vpColVector(pose.getThetaUVector()) - vpColVector(pose_truth.getThetaUVector()); double error_trans = sqrt(error_translation.sumSquare() / 3); double error_orientation = sqrt(error_thetau.sumSquare() / 3); std::cout << "\t\t\tTranslation error: " << error_trans << " / Rotation error: " << error_orientation - << std::endl; + << std::endl; CHECK((error_trans < errorTranslationThresh[id] && error_orientation < errorRotationThresh[id])); } } @@ -299,12 +301,12 @@ TEST_CASE("Apriltag pose estimation test", "[apriltag_pose_estimation_test]") const vpHomogeneousMatrix &cMo_truth = groundTruthPoses[id]; const vpPoseVector pose_truth(cMo_truth); - vpColVector error_translation = pose.getTranslationVector() - pose_truth.getTranslationVector(); + vpColVector error_translation = vpColVector(pose.getTranslationVector() - pose_truth.getTranslationVector()); vpColVector error_thetau = vpColVector(pose.getThetaUVector()) - vpColVector(pose_truth.getThetaUVector()); double error_trans = sqrt(error_translation.sumSquare() / 3); double error_orientation = sqrt(error_thetau.sumSquare() / 3); std::cout << "\t\t\tTranslation error: " << error_trans << " / Rotation error: " << error_orientation - << std::endl; + << std::endl; if (std::find(ignoreTests.begin(), ignoreTests.end(), FailedTestCase(family, method, static_cast(idx))) == ignoreTests.end()) { CHECK((error_trans < errorTranslationThresh[id] && error_orientation < errorRotationThresh[id])); @@ -344,12 +346,12 @@ TEST_CASE("Apriltag pose estimation test", "[apriltag_pose_estimation_test]") const vpHomogeneousMatrix cMo_truth = groundTruthPoses[id] * oMo2; const vpPoseVector pose_truth(cMo_truth); - vpColVector error_translation = pose.getTranslationVector() - pose_truth.getTranslationVector(); + vpColVector error_translation = vpColVector(pose.getTranslationVector() - pose_truth.getTranslationVector()); vpColVector error_thetau = vpColVector(pose.getThetaUVector()) - vpColVector(pose_truth.getThetaUVector()); double error_trans = sqrt(error_translation.sumSquare() / 3); double error_orientation = sqrt(error_thetau.sumSquare() / 3); std::cout << "\t\t\tTranslation error: " << error_trans << " / Rotation error: " << error_orientation - << std::endl; + << std::endl; if (std::find(ignoreTests.begin(), ignoreTests.end(), FailedTestCase(family, method, static_cast(idx))) == ignoreTests.end()) { CHECK((error_trans < errorTranslationThresh[id] && error_orientation < errorRotationThresh[id])); @@ -380,8 +382,8 @@ TEST_CASE("Apriltag corners accuracy test", "[apriltag_corners_accuracy_test]") std::map > > groundTruthCorners; for (const auto &kv : apriltagMap) { std::string filename = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), - std::string("AprilTag/benchmark/640x480/corners_") + kv.second + std::string(".txt")); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), + std::string("AprilTag/benchmark/640x480/corners_") + kv.second + std::string(".txt")); std::ifstream file(filename); REQUIRE(file.is_open()); @@ -403,8 +405,8 @@ TEST_CASE("Apriltag corners accuracy test", "[apriltag_corners_accuracy_test]") auto family = kv.first; std::cout << "\nApriltag family: " << family << std::endl; std::string filename = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), - std::string("AprilTag/benchmark/640x480/") + kv.second + std::string("_640x480.png")); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), + std::string("AprilTag/benchmark/640x480/") + kv.second + std::string("_640x480.png")); REQUIRE(vpIoTools::checkFilename(filename)); vpImage I; @@ -463,7 +465,7 @@ TEST_CASE("Apriltag regression test", "[apriltag_regression_test]") std::map mapOfTagsGroundTruth; { std::string filename_ground_truth = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/ground_truth_detection.txt"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/ground_truth_detection.txt"); std::ifstream file_ground_truth(filename_ground_truth.c_str()); REQUIRE(file_ground_truth.is_open()); std::string message = ""; @@ -482,7 +484,7 @@ TEST_CASE("Apriltag regression test", "[apriltag_regression_test]") std::map mapOfPosesGroundTruth; { std::string filename_ground_truth = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/ground_truth_pose.txt"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/ground_truth_pose.txt"); std::ifstream file_ground_truth(filename_ground_truth.c_str()); REQUIRE(file_ground_truth.is_open()); std::string message = ""; @@ -502,7 +504,8 @@ TEST_CASE("Apriltag regression test", "[apriltag_regression_test]") TagGroundTruth current(message, p); if (it == mapOfTagsGroundTruth.end()) { std::cerr << "Problem with tag decoding (tag_family or id): " << message << std::endl; - } else if (it->second != current) { + } + else if (it->second != current) { std::cerr << "Problem, current detection:\n" << current << "\nReference:\n" << it->second << std::endl; } REQUIRE(it != mapOfTagsGroundTruth.end()); @@ -538,7 +541,7 @@ TEST_CASE("Apriltag regression test", "[apriltag_regression_test]") TEST_CASE("Apriltag copy constructor test", "[apriltag_copy_constructor_test]") { const std::string filename = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/benchmark/640x480/tag21_07_640x480.png"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/benchmark/640x480/tag21_07_640x480.png"); REQUIRE(vpIoTools::checkFilename(filename)); vpImage I; @@ -604,7 +607,7 @@ TEST_CASE("Apriltag copy constructor test", "[apriltag_copy_constructor_test]") TEST_CASE("Apriltag assignment operator test", "[apriltag_assignment_operator_test]") { const std::string filename = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/benchmark/640x480/tag21_07_640x480.png"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/benchmark/640x480/tag21_07_640x480.png"); REQUIRE(vpIoTools::checkFilename(filename)); vpImage I; @@ -670,7 +673,7 @@ TEST_CASE("Apriltag assignment operator test", "[apriltag_assignment_operator_te TEST_CASE("Apriltag getTagsPoints3D test", "[apriltag_get_tags_points3D_test]") { const std::string filename = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/benchmark/640x480/tag21_07_640x480.png"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "AprilTag/benchmark/640x480/tag21_07_640x480.png"); REQUIRE(vpIoTools::checkFilename(filename)); vpImage I; @@ -682,7 +685,7 @@ TEST_CASE("Apriltag getTagsPoints3D test", "[apriltag_get_tags_points3D_test]") const double familyScale = 5.0 / 9; const double tagSize = 0.25; std::map tagsSize = { - {-1, tagSize * familyScale}, {3, tagSize / 2 * familyScale}, {4, tagSize / 2 * familyScale}}; + {-1, tagSize * familyScale}, {3, tagSize / 2 * familyScale}, {4, tagSize / 2 * familyScale} }; vpDetectorAprilTag detector(tagFamily, poseEstimationMethod);