2 #include <gtest/gtest.h>
3 #include <camera_calibration_parsers/parse.h>
5 #include <opencv2/highgui/highgui.hpp>
7 #include <sensor_msgs/CameraInfo.h>
17 if (camera_ns ==
"/camera")
18 throw "Must remap 'camera' to the camera namespace.";
26 double D[] = {-0.363528858080088, 0.16117037733986861, -8.1109585007538829e-05, -0.00044776712298447841, 0.0};
27 double K[] = {430.15433020105519, 0.0, 311.71339830549732,
28 0.0, 430.60920415473657, 221.06824942698509,
30 double R[] = {0.99806560714807102, 0.0068562422224214027, 0.061790256276695904,
31 -0.0067522959054715113, 0.99997541519165112, -0.0018909025066874664,
32 -0.061801701660692349, 0.0014700186639396652, 0.99808736527268516};
33 double P[] = {295.53402059708782, 0.0, 285.55760765075684, 0.0,
34 0.0, 295.53402059708782, 223.29617881774902, 0.0,
50 const cv::Scalar color = cv::Scalar(255, 255, 255);
53 const int thickness = 7;
58 cv::Point(0, y), cv::Point(
cam_info_.width, y),
59 color, type, thickness);
65 cv::Point(x, 0), cv::Point(x,
cam_info_.height),
66 color, type, thickness);
102 ROS_FATAL(
"cv_bridge exception: %s", e.what());
123 bool wait_for_topic =
true;
124 while (wait_for_topic)
130 if (cam_sub_.getNumPublishers() > 0)
131 wait_for_topic =
false;
142 const double diff_threshold = 10000.0;
147 while (!has_new_image_)
154 error = cv::norm(distorted_image_, received_image_, cv::NORM_L1);
156 EXPECT_GT(error, diff_threshold);
161 sensor_msgs::CameraInfo cam_info_orig = cam_info_;
162 cam_info_.D[0] = 0.0;
164 while (!has_new_image_)
169 error = cv::norm(distorted_image_, received_image_, cv::NORM_L1);
170 EXPECT_GT(error, diff_threshold);
173 cam_info_.D.assign(cam_info_.D.size(), 0);
175 while (!has_new_image_)
180 error = cv::norm(distorted_image_, received_image_, cv::NORM_L1);
187 while (!has_new_image_)
192 error = cv::norm(distorted_image_, received_image_, cv::NORM_L1);
197 cam_info_ = cam_info_orig;
200 int main(
int argc,
char** argv)
202 ros::init(argc, argv,
"image_proc_test_rectify");
203 testing::InitGoogleTest(&argc, argv);
204 return RUN_ALL_TESTS();