math.h
Go to the documentation of this file.
1 namespace laserscan_kinect {
2 
4 
8 inline double lengthOfVector(const cv::Point3d& vec) {
9  return sqrt(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z);
10 }
11 
15 inline double angleBetweenRays(const cv::Point3d& ray1, const cv::Point3d& ray2) {
16  double dot = ray1.x * ray2.x + ray1.y * ray2.y + ray1.z * ray2.z;
17  return acos(dot / (lengthOfVector(ray1) * lengthOfVector(ray2)));
18 }
19 
23 inline void calcFieldOfView(const image_geometry::PinholeCameraModel& camera_model,
24  const cv::Point2d && left, const cv::Point2d && center,
25  const cv::Point2d && right, double & min, double & max) {
26 
27  cv::Point2d rect_pixel_left = camera_model.rectifyPoint(left);
28  cv::Point3d left_ray = camera_model.projectPixelTo3dRay(rect_pixel_left);
29 
30  cv::Point2d rect_pixel_right = camera_model.rectifyPoint(right);
31  cv::Point3d right_ray = camera_model.projectPixelTo3dRay(rect_pixel_right);
32 
33  cv::Point2d rect_pixel_center = camera_model.rectifyPoint(center);
34  cv::Point3d center_ray = camera_model.projectPixelTo3dRay(rect_pixel_center);
35 
36  min = -angleBetweenRays(center_ray, right_ray);
37  max = angleBetweenRays(left_ray, center_ray);
38  }
39 
40 }
cv::Point3d projectPixelTo3dRay(const cv::Point2d &uv_rect) const
double lengthOfVector(const cv::Point3d &vec)
lengthOfVector calculate the length of the 3D vector
Definition: math.h:8
void calcFieldOfView(const image_geometry::PinholeCameraModel &camera_model, const cv::Point2d &&left, const cv::Point2d &&center, const cv::Point2d &&right, double &min, double &max)
fieldOfView calculates field of view (angle)
Definition: math.h:23
cv::Point2d rectifyPoint(const cv::Point2d &uv_raw) const
double angleBetweenRays(const cv::Point3d &ray1, const cv::Point3d &ray2)
angleBetweenRays calculates angle between two rays in degrees
Definition: math.h:15


laserscan_kinect
Author(s): Michal Drwiega (http://www.mdrwiega.com)
autogenerated on Wed May 5 2021 02:56:14