37 #include <opencv2/imgproc/imgproc.hpp> 46 cv::Mat_<cv::Vec2f> image, std::vector<float>& positions, std::vector<float>& velocities)
48 const unsigned int N = points.size();
51 cv::Mat_<float> map_x_mat(N, 1);
52 cv::Mat_<float> map_y_mat(N, 1);
55 for (
unsigned int i=0; i<N; i++)
57 map_x_mat(i) = points[i].x;
58 map_y_mat(i) = points[i].y;
62 cv::Mat_<cv::Vec2f> dest_mat(N, 1);
65 cv::remap(image, dest_mat, map_x_mat, map_y_mat, cv::INTER_LINEAR, cv::BORDER_WRAP);
70 for (
unsigned int i=0; i<N; i++)
72 positions[i] = dest_mat(i)[0];
73 velocities[i] = dest_mat(i)[1];
81 const calibration_msgs::DenseLaserSnapshot& snapshot,
82 std::vector<float>& angles,
83 std::vector<float>& ranges)
85 const unsigned int N = points.size();
88 for (
unsigned int i=0; i<N; i++)
90 if (points[i].x < 0 ||
91 points[i].x > snapshot.readings_per_scan-1 ||
93 points[i].y > snapshot.num_scans-1 )
100 cv::Mat_<float> range_image(snapshot.num_scans, snapshot.readings_per_scan, const_cast<float*>(&snapshot.ranges[0]));
103 cv::Mat_<float> map_x_mat(N, 1);
104 cv::Mat_<float> map_y_mat(N, 1);
107 for (
unsigned int i=0; i<N; i++)
109 map_x_mat(i) = points[i].x;
110 map_y_mat(i) = points[i].y;
115 cv::Mat_<float> ranges_mat(N, 1, &ranges[0]);
118 cv::remap(range_image, ranges_mat, map_x_mat, map_y_mat, cv::INTER_LINEAR, cv::BORDER_WRAP);
122 for (
unsigned int i=0; i<N; i++)
123 angles[i] = snapshot.angle_min + points[i].x*snapshot.angle_increment;
bool interpSnapshot(const std::vector< geometry_msgs::Point > &points, const calibration_msgs::DenseLaserSnapshot &snapshot, std::vector< float > &pointing_angles, std::vector< float > &ranges)
bool interp(const std::vector< geometry_msgs::Point > &points, cv::Mat_< cv::Vec2f > image, std::vector< float > &positions, std::vector< float > &velocities)