PointCloudTransform.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * TI Voxel Lib component.
  3. *
  4. * Copyright (c) 2014 Texas Instruments Inc.
  5. */
  6. #ifndef VOXEL_POINTCLOUD_TRANSFORM_H
  7. #define VOXEL_POINTCLOUD_TRANSFORM_H
  8. #include "Point.h"
  9. #include "Common.h"
  10. #include "Frame.h"
  11. #include "VoxelExports.h"
  12. #include <float.h>
  13. #define POINT_INVALID FLT_MAX
  14. namespace Voxel
  15. {
  16. /**
  17. * \addtogroup Frm
  18. * @{
  19. */
  20. class VOXEL_EXPORT PointCloudTransform
  21. {
  22. public:
  23. uint32_t left, top; // Image top-left corner
  24. uint32_t width, height; // sensor width and height
  25. uint32_t rowsToMerge, columnsToMerge; // Binning
  26. float fx, fy; // x- and y- focal distance
  27. float cx, cy; // image center
  28. float k1, k2, k3; // radial distortion parameters
  29. float p1, p2; // tangential distortion parameters
  30. Vector<Point> directions; // Directional array
  31. // Clippings
  32. Point leftClippingNormal;
  33. Point rightClippingNormal;
  34. Point topClippingNormal;
  35. Point bottomClippingNormal;
  36. // Estimation errors
  37. float fxError, fyError;
  38. float cxError, cyError;
  39. float k1Error, k2Error, k3Error;
  40. float p1Error, p2Error;
  41. float pixelErrorX, pixelErrorY;
  42. // Checkerboard information
  43. int nCornersPerImages;
  44. int nImages;
  45. Point &getDirection(int row, int col);
  46. public:
  47. PointCloudTransform(uint32_t left, uint32_t top, uint32_t width, uint32_t height,
  48. uint32_t rowsToMerge, uint32_t columnsToMerge,
  49. float fx, float fy, float cx, float cy,
  50. float k1, float k2, float k3, float p1, float p2);
  51. void calcAperatureAngleRadians(int &horizontalAperatureAngle, float &verticalAperatureAngle);
  52. void rescaleParameters(int width, int height);
  53. Point worldToImage(const Point &p);
  54. Point imageToWorld(const Point &p, float depth);
  55. bool depthToPointCloud(const Vector<float> &distances, PointCloudFrame &pointCloudFrame);
  56. private:
  57. Point _screenToNormalizedScreen(const Point &screen, bool verify);
  58. Point _normalizedScreenToScreen(const Point &normalizedScreen);
  59. Point _lensCorrection(const Point &normalizedScreen);
  60. bool _computeConcaveMirrorBorders(int width, int height, double &minx, double &maxX,
  61. double &minY, double &maxY);
  62. bool _computeConcaveMirrorBordersOuter(int width, int height, double &minX, double &maxX,
  63. double &minY, double &maxY);
  64. void _computeConcaveMirror(int width, int height,
  65. Vector<double> &leftArr, Vector<double> &rightArr,
  66. Vector<double> &topArr, Vector<double> &bottomArr);
  67. void _init();
  68. Point _normalizedScreenToUnitWorld(const Point &normalizedScreen);
  69. void _computeClippingPlanes();
  70. };
  71. typedef Ptr<PointCloudTransform> PointCloudTransformPtr;
  72. /**
  73. * @}
  74. */
  75. }
  76. #endif // VOXEL_POINTCLOUD_TRANSFORM_H