MRPT  2.0.3
chessboard_stereo_camera_calib_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
11 #include <mrpt/config.h>
13 #include <test_mrpt_common.h>
14 
15 #if MRPT_HAS_OPENCV
17 #else
18 TEST(Vision, DISABLED_checkerBoardStereoCalibration)
19 #endif
20 {
21  using namespace std::string_literals;
22 
26 
27  // Test: calib with real data:
28  const auto dir =
29  mrpt::UNITTEST_BASEDIR + "/share/mrpt/datasets/stereo-calib/"s;
30 
31  const unsigned int NUM_IMGS = 4;
32  images.resize(NUM_IMGS);
33  for (unsigned int i = 0; i < NUM_IMGS; i++)
34  {
35  auto fil = dir + mrpt::format("%u_left.jpg", i);
36  if (!images[i].left.img_original.loadFromFile(fil))
37  {
38  GTEST_FAIL() << "Error loading: " << fil;
39  return;
40  }
41  fil = dir + mrpt::format("%u_right.jpg", i);
42  if (!images[i].right.img_original.loadFromFile(fil))
43  {
44  GTEST_FAIL() << "Error loading: " << fil;
45  return;
46  }
47  }
48 
49  // Pattern images from the "Malaga Urban Dataset 2010" (BumbleBee2 camera)
59  params.verbose = false;
60 
62 
63  // Checks:
64  EXPECT_LT(out.final_rmse, 3.0);
65  EXPECT_GT(out.final_iters, 10UL);
66 
67  EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005);
71 
73  for (unsigned int i = 0; i < NUM_IMGS; i++)
74  EXPECT_TRUE(out.image_pair_was_used[i]) << "i=" << i;
75 
76 #if 0 // Debug:
77  std::cout << out.right2left_camera_pose.asString() << "\n";
78  for (unsigned int i = 0; i < images.size(); i++)
79  {
80  images[i].left.img_checkboard.saveToFile(
81  mrpt::format("/tmp/stereo_%03u_check_L.png", i));
82  images[i].right.img_checkboard.saveToFile(
83  mrpt::format("/tmp/stereo_%03u_check_R.png", i));
84  }
85  std::cout << out.cam_params.dumpAsText();
86 #endif
87 
88  EXPECT_TRUE(ok);
89 }
90 
91 #if MRPT_HAS_OPENCV
92 TEST(Vision, checkerBoardStereoCalibration_empty)
93 #else
94 TEST(Vision, DISABLED_checkerBoardStereoCalibration_empty)
95 #endif
96 {
100  params.verbose = false;
101 
102  const bool ok =
104  EXPECT_FALSE(ok);
105 }
mrpt::vision::TStereoCalibParams::optimize_k2
bool optimize_k2
Definition: chessboard_stereo_camera_calib.h:79
EXPECT_TRUE
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
mrpt::math::TPose3DQuat::qr
double qr
Unit quaternion part, qr,qx,qy,qz.
Definition: TPose3DQuat.h:29
mrpt::math::TPose3DQuat::x
double x
Translation in x,y,z.
Definition: TPose3DQuat.h:27
mrpt::vision::TStereoCalibParams::check_size_y
unsigned int check_size_y
Definition: chessboard_stereo_camera_calib.h:58
TEST
TEST(ICP_SLAM_App, MapFromRawlog_PointMap)
Definition: ICP_SLAM_App_unittest.cpp:80
mrpt::vision::checkerBoardStereoCalibration
bool checkerBoardStereoCalibration(TCalibrationStereoImageList &images, const TStereoCalibParams &params, TStereoCalibResults &out_results)
Optimize the calibration parameters of a stereo camera or a RGB+D (Kinect) camera.
Definition: chessboard_stereo_camera_calib.cpp:44
mrpt::vision::TStereoCalibParams
Input parameters for mrpt::vision::checkerBoardStereoCalibration.
Definition: chessboard_stereo_camera_calib.h:55
mrpt::vision::TStereoCalibResults::image_pair_was_used
std::vector< bool > image_pair_was_used
true if a checkerboard was correctly detected in both left/right images.
Definition: chessboard_stereo_camera_calib.h:116
chessboard_stereo_camera_calib.h
mrpt::vision::TStereoCalibResults::cam_params
mrpt::img::TStereoCamera cam_params
Recovered parameters of the stereo camera.
Definition: chessboard_stereo_camera_calib.h:105
mrpt::vision::TStereoCalibParams::check_squares_length_X_meters
double check_squares_length_X_meters
The size of each square in the checkerboard, in meters, in the "X" & Y" axes.
Definition: chessboard_stereo_camera_calib.h:61
out
mrpt::vision::TStereoCalibResults out
Definition: chessboard_stereo_camera_calib_unittest.cpp:25
images
mrpt::vision::TCalibrationStereoImageList images
Definition: chessboard_stereo_camera_calib_unittest.cpp:20
mrpt::vision::TStereoCalibResults::right2left_camera_pose
mrpt::poses::CPose3D right2left_camera_pose
The pose of the left camera as seen from the right camera.
Definition: chessboard_stereo_camera_calib.h:107
EXPECT_NEAR
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
mrpt::math::TPose3DQuat::y
double y
Definition: TPose3DQuat.h:27
mrpt::vision::TStereoCalibParams::check_size_x
unsigned int check_size_x
The number of squares in the checkerboard in the "X" & "Y" direction.
Definition: chessboard_stereo_camera_calib.h:58
mrpt::img::TStereoCamera::rightCameraPose
mrpt::math::TPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
Definition: TStereoCamera.h:31
EXPECT_EQ
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
EXPECT_LT
EXPECT_LT(out.final_rmse, 3.0)
mrpt::vision::TStereoCalibResults
Output results for mrpt::vision::checkerBoardStereoCalibration.
Definition: chessboard_stereo_camera_calib.h:100
mrpt::math::TPose3DQuat::z
double z
Definition: TPose3DQuat.h:27
mrpt::vision::TStereoCalibResults::final_iters
size_t final_iters
Final number of optimization iterations executed.
Definition: chessboard_stereo_camera_calib.h:121
params
mrpt::vision::TStereoCalibParams params
Definition: chessboard_stereo_camera_calib_unittest.cpp:24
mrpt::vision::TStereoCalibParams::verbose
bool verbose
Show progress messages to std::cout console (default=true)
Definition: chessboard_stereo_camera_calib.h:66
mrpt::vision::TStereoCalibResults::final_rmse
double final_rmse
Final reprojection square Root Mean Square Error (in pixels).
Definition: chessboard_stereo_camera_calib.h:119
mrpt::vision::TStereoCalibParams::optimize_t1
bool optimize_t1
Definition: chessboard_stereo_camera_calib.h:80
mrpt::vision::TCalibrationStereoImageList
std::vector< TImageStereoCalibData > TCalibrationStereoImageList
A list of images, used in checkerBoardStereoCalibration.
Definition: chessboard_stereo_camera_calib.h:137
dir
const auto dir
Definition: chessboard_stereo_camera_calib_unittest.cpp:28
mrpt::vision::TStereoCalibParams::check_squares_length_Y_meters
double check_squares_length_Y_meters
Definition: chessboard_stereo_camera_calib.h:62
mrpt::vision::TStereoCalibParams::optimize_t2
bool optimize_t2
Definition: chessboard_stereo_camera_calib.h:80
mrpt::img::TStereoCamera::dumpAsText
std::string dumpAsText() const
Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile.
Definition: TStereoCamera.cpp:97
ok
bool ok
Definition: chessboard_stereo_camera_calib_unittest.cpp:61
EXPECT_GT
EXPECT_GT(out.final_iters, 10UL)
mrpt::format
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition: format.h:26
mrpt::vision::TStereoCalibParams::optimize_k1
bool optimize_k1
Select which distortion parameters (of both left/right cameras) will be optimzed: k1,...
Definition: chessboard_stereo_camera_calib.h:79
mrpt::vision::TStereoCalibParams::optimize_k3
bool optimize_k3
Definition: chessboard_stereo_camera_calib.h:79
mrpt::poses::CPose3D::asString
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[x y z yaw pitch roll]",...
Definition: CPose3D.h:618
NUM_IMGS
const unsigned int NUM_IMGS
Definition: chessboard_stereo_camera_calib_unittest.cpp:31



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 29 13:06:46 UTC 2020