MRPT  2.0.4
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 }
EXPECT_LT(out.final_rmse, 3.0)
bool optimize_k1
Select which distortion parameters (of both left/right cameras) will be optimzed: k1...
double final_rmse
Final reprojection square Root Mean Square Error (in pixels).
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
EXPECT_GT(out.final_iters, 10UL)
mrpt::vision::TCalibrationStereoImageList images
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition: format.h:26
std::vector< bool > image_pair_was_used
true if a checkerboard was correctly detected in both left/right images.
mrpt::vision::TStereoCalibParams params
size_t final_iters
Final number of optimization iterations executed.
double check_squares_length_X_meters
The size of each square in the checkerboard, in meters, in the "X" & Y" axes.
mrpt::img::TStereoCamera cam_params
Recovered parameters of the stereo camera.
TEST(ICP_SLAM_App, MapFromRawlog_PointMap)
Input parameters for mrpt::vision::checkerBoardStereoCalibration.
double x
Translation in x,y,z.
Definition: TPose3DQuat.h:27
std::string dumpAsText() const
Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile.
double qr
Unit quaternion part, qr,qx,qy,qz.
Definition: TPose3DQuat.h:29
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
unsigned int check_size_x
The number of squares in the checkerboard in the "X" & "Y" direction.
bool checkerBoardStereoCalibration(TCalibrationStereoImageList &images, const TStereoCalibParams &params, TStereoCalibResults &out_results)
Optimize the calibration parameters of a stereo camera or a RGB+D (Kinect) camera.
const unsigned int NUM_IMGS
mrpt::vision::TStereoCalibResults out
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
mrpt::poses::CPose3D right2left_camera_pose
The pose of the left camera as seen from the right camera.
mrpt::math::TPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
Definition: TStereoCamera.h:31
bool verbose
Show progress messages to std::cout console (default=true)
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
Output results for mrpt::vision::checkerBoardStereoCalibration.
std::vector< TImageStereoCalibData > TCalibrationStereoImageList
A list of images, used in checkerBoardStereoCalibration.



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020