16 #include <unordered_set>
37 float pixelSize_mm[2];
45 float principal_point[2];
51 assert(pixelSize_mm[1] > 0);
52 return (vertFocal_pix * pixelSize_mm[0]) / pixelSize_mm[1];
58 NO_DISTORTION_MODEL = 0,
59 SIMPLE_RADIAL_DISTORTION =
63 EXTENDED_RADIAL_DISTORTION =
70 typedef QSharedPointer<LensDistortionParameters>
Shared;
82 typedef QSharedPointer<RadialDistortionParameters>
Shared;
89 return SIMPLE_RADIAL_DISTORTION;
102 typedef QSharedPointer<RadialDistortionParameters>
Shared;
110 return EXTENDED_RADIAL_DISTORTION;
126 typedef QSharedPointer<BrownDistortionParameters>
Shared;
133 return BROWN_DISTORTION;
140 float principalPointOffset[2];
142 float linearDisparityParams[2];
145 float K_BrownParams[3];
147 float P_BrownParams[2];
207 return m_intrinsicParams.vertFocal_pix;
211 return m_intrinsicParams.horizFocal_pix();
218 return m_intrinsicParams.vFOV_rad;
223 return m_intrinsicParams;
230 return m_distortionParams;
234 m_distortionParams =
params;
249 inline void drawFrustum(
bool state) { m_frustumInfos.drawFrustum = state; }
253 return m_frustumInfos.drawSidePlanes;
258 m_frustumInfos.drawSidePlanes = state;
292 bool withLensError =
true)
const;
308 bool withLensCorrection =
true)
const;
322 bool withLensError =
true)
const;
337 bool withLensCorrection =
true)
const;
377 KeyPoint(
float Px,
float Py,
unsigned indexInCloud)
378 : x(Px), y(Py), index(indexInCloud) {}
391 std::vector<KeyPoint>& keypointsImage)
const;
406 std::vector<KeyPoint>& keypointsImage,
408 double* minCorner =
nullptr,
409 double* maxCorner =
nullptr,
410 double* realCorners =
nullptr)
const;
427 bool undistortImages =
true,
428 double* minCorner =
nullptr,
429 double* maxCorner =
nullptr,
430 double* realCorners =
nullptr)
const;
444 std::vector<ccImage*> images,
449 QDir* outputDir =
nullptr,
450 std::vector<ccImage*>* orthoRectifiedImages =
nullptr,
451 std::vector<std::pair<double, double>>* relativePos =
nullptr);
469 std::vector<KeyPoint>& keypointsImage,
641 unsigned char level)
const {
644 std::unordered_set<cloudViewer::DgmOctree::CellCode>::const_iterator
670 std::vector<std::pair<unsigned, CCVector3>>& pointsToTest,
671 std::vector<unsigned>& inCameraFrustum,
672 const float planesCoefficients[6][4],
694 const float planesCoefficients[6][4],
716 const float planesCoefficients[6][4],
725 std::unordered_set<cloudViewer::DgmOctree::CellCode>
728 std::unordered_set<cloudViewer::DgmOctree::CellCode>
731 std::unordered_set<cloudViewer::DgmOctree::CellCode>
float PointCoordinateType
Type of the coordinates of a (N-D) point.
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
std::shared_ptr< core::Tensor > image
cmdLineReadable * params[]
Camera (projective) sensor.
const ecvColor::Rgb & getPlaneColor() const
ccImage * orthoRectifyAsImage(const ccImage *image, cloudViewer::GenericIndexedCloud *keypoints3D, std::vector< KeyPoint > &keypointsImage, double &pixelSize, double *minCorner=nullptr, double *maxCorner=nullptr, double *realCorners=nullptr) const
Projective ortho-rectification of an image (as image)
static float ConvertFocalPixToMM(float focal_pix, float ccdPixelSize_mm)
Helper: converts camera focal from pixels to mm.
bool computeGlobalPlaneCoefficients(float planeCoefficients[6][4], CCVector3 ptsFrustum[8], CCVector3 edges[6], CCVector3 ¢er)
ccCameraSensor()
Default constructor.
FrustumInformation m_frustumInfos
Frustum information structure.
bool fromImageCoordToLocalCoord(const CCVector2 &imageCoord, CCVector3 &localCoord, PointCoordinateType depth, bool withLensCorrection=true) const
ecvColor::Rgb m_plane_color
void computeProjectionMatrix()
Compute the projection matrix (from intrinsic parameters)
LensDistortionParameters::Shared m_distortionParams
Lens distortion parameters.
virtual CV_CLASS_ENUM getClassID() const override
Returns class ID.
void setVerticalFov_rad(float fov_rad)
Sets the (vertical) field of view in radians.
bool computeOrthoRectificationParams(const ccImage *image, cloudViewer::GenericIndexedCloud *keypoints3D, std::vector< KeyPoint > &keypointsImage, double a[3], double b[3], double c[3]) const
Computes ortho-rectification parameters for a given image.
float getVerticalFov_rad() const
Returns the (vertical) field of view in radians.
const cloudViewer::geometry::LineSet & getNearPlane() const
cloudViewer::geometry::LineSet m_arrow
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
ccPointCloud * orthoRectifyAsCloud(const ccImage *image, cloudViewer::GenericIndexedCloud *keypoints3D, std::vector< KeyPoint > &keypointsImage) const
Projective ortho-rectification of an image (as cloud)
bool computeFrustumCorners()
Computes the eight corners of the frustum.
bool frustumIsDrawn() const
Returns whether the frustum should be displayed or not.
ccImage * orthoRectifyAsImageDirect(const ccImage *image, PointCoordinateType altitude, double &pixelSize, bool undistortImages=true, double *minCorner=nullptr, double *maxCorner=nullptr, double *realCorners=nullptr) const
Direct ortho-rectification of an image (as image)
float getVertFocal_pix() const
Returns vertical focal (in pixels)
bool fromGlobalCoordToImageCoord(const CCVector3 &globalCoord, CCVector2 &imageCoord, bool withLensError=true) const
CCVector3 computeUpperLeftPoint() const
Used internally for display.
void drawFrustumPlanes(bool state)
Sets whether the frustum planes should be displayed or not.
const cloudViewer::geometry::LineSet & getSideLines() const
static float ConvertFocalMMToPix(float focal_mm, float ccdPixelSize_mm)
Helper: converts camera focal from mm to pixels.
void setVertFocal_pix(float vertFocal_pix)
Sets focal (in pixels)
bool frustumPlanesAreDrawn() const
Returns whether the frustum planes should be displayed or not.
short minimumFileVersion_MeOnly() const override
bool isGlobalCoordInFrustum(const CCVector3 &globalCoord) const
Tests if a 3D point is in the field of view of the camera.
void setIntrinsicParameters(const IntrinsicParameters ¶ms)
Sets intrinsic parameters.
static float ComputeFovRadFromFocalMm(float focal_mm, float ccdSize_mm)
Helper: deduces camera f.o.v. (in radians) from focal (in mm)
const IntrinsicParameters & getIntrinsicParameters() const
Returns intrinsic parameters.
bool fromGlobalCoordToLocalCoord(const CCVector3 &globalCoord, CCVector3 &localCoord) const
cloudViewer::geometry::LineSet m_nearPlane
float getHorizFocal_pix() const
Returns horizontal focal (in pixels)
const cloudViewer::geometry::LineSet & getArrow() const
cloudViewer::geometry::LineSet m_axis
virtual ~ccCameraSensor() override
Destructor.
bool fromLocalCoordToGlobalCoord(const CCVector3 &localCoord, CCVector3 &globalCoord) const
void setPlaneColor(ecvColor::Rgb color)
static float ComputeFovRadFromFocalPix(float focal_pix, int imageSize_pix)
Helper: deduces camera f.o.v. (in radians) from focal (in pixels)
virtual void hideShowDrawings(CC_DRAW_CONTEXT &context) override
virtual ccBBox getOwnFitBB(ccGLMatrix &trans) override
Returns best-fit bounding-box (if available)
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Draws the entity only (not its children)
cloudViewer::geometry::LineSet m_sideLines
const cloudViewer::geometry::LineSet & getAxis() const
const LensDistortionParameters::Shared & getDistortionParameters() const
Returns uncertainty parameters.
virtual bool applyViewport() override
Apply sensor 'viewport' to a 3D view.
virtual ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
bool getProjectionMatrix(ccGLMatrix &matrix)
Returns the camera projection matrix.
ccImage * undistort(ccImage *image, bool inplace=true) const
Undistorts an image based on the sensor distortion parameters.
IntrinsicParameters m_intrinsicParams
Camera intrinsic parameters.
ccCameraSensor(const IntrinsicParameters &iParams)
bool computeUncertainty(const CCVector2 &pixel, const float depth, Vector3Tpl< ScalarType > &sigma) const
bool fromLocalCoordToImageCoord(const CCVector3 &localCoord, CCVector2 &imageCoord, bool withLensError=true) const
virtual bool isSerializable() const override
Returns whether object is serializable of not.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
bool computeUncertainty(cloudViewer::ReferenceCloud *points, std::vector< Vector3Tpl< ScalarType >> &accuracy)
QImage undistort(const QImage &image) const
Undistorts an image based on the sensor distortion parameters.
bool fromImageCoordToGlobalCoord(const CCVector2 &imageCoord, CCVector3 &globalCoord, PointCoordinateType z0, bool withLensCorrection=true) const
bool m_projectionMatrixIsValid
Whether the intrinsic matrix is valid or not.
bool fromRealImCoordToIdealImCoord(const CCVector2 &real, CCVector2 &ideal) const
DistortionModel
Supported distortion models.
virtual void clearDrawings() override
double getFocalLength() const
ccCameraSensor(const ccCameraSensor &sensor)
Copy constructor.
void setDistortionParameters(LensDistortionParameters::Shared params)
Sets uncertainty parameters.
ccGLMatrix m_projectionMatrix
Intrinsic parameters matrix.
void drawFrustum(bool state)
Sets whether the frustum should be displayed or not.
static bool OrthoRectifyAsImages(std::vector< ccImage * > images, double a[], double b[], double c[], unsigned maxSize, QDir *outputDir=nullptr, std::vector< ccImage * > *orthoRectifiedImages=nullptr, std::vector< std::pair< double, double >> *relativePos=nullptr)
Projective ortho-rectification of multiple images (as image files)
Float version of ccGLMatrixTpl.
void computeFrustumIntersectionWithOctree(std::vector< std::pair< unsigned, CCVector3 >> &pointsToTest, std::vector< unsigned > &inCameraFrustum, const float planesCoefficients[6][4], const CCVector3 ptsFrustum[8], const CCVector3 edges[6], const CCVector3 ¢er)
cloudViewer::DgmOctree * m_associatedOctree
OctreeCellVisibility
Definition of the state of a cell compared to a frustum.
bool build(cloudViewer::DgmOctree *octree)
Prepares structure for frustum filtering.
OctreeCellVisibility positionFromFrustum(cloudViewer::DgmOctree::CellCode truncatedCode, unsigned char level) const
Returns the cell visibility.
std::unordered_set< cloudViewer::DgmOctree::CellCode > m_cellsBuilt[cloudViewer::DgmOctree::MAX_OCTREE_LEVEL+1]
void computeFrustumIntersectionByLevel(unsigned char level, cloudViewer::DgmOctree::CellCode parentTruncatedCode, OctreeCellVisibility parentResult, const float planesCoefficients[6][4], const CCVector3 ptsFrustum[8], const CCVector3 edges[6], const CCVector3 ¢er)
OctreeCellVisibility separatingAxisTest(const CCVector3 &bbMin, const CCVector3 &bbMax, const float planesCoefficients[6][4], const CCVector3 frustumCorners[8], const CCVector3 frustumEdges[6], const CCVector3 &frustumCenter)
Separating Axis Test.
std::unordered_set< cloudViewer::DgmOctree::CellCode > m_cellsInFrustum[cloudViewer::DgmOctree::MAX_OCTREE_LEVEL+1]
ccOctreeFrustumIntersector()
Default constructor.
std::unordered_set< cloudViewer::DgmOctree::CellCode > m_cellsIntersectFrustum[cloudViewer::DgmOctree::MAX_OCTREE_LEVEL+1]
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Generic sensor interface.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
The octree structure used throughout the library.
unsigned CellCode
Type of the code of an octree cell.
static const int MAX_OCTREE_LEVEL
Max octree subdivision level.
A generic 3D point cloud with index-based point access.
A very simple point cloud (no point duplication)
LineSet define a sets of lines in 3D. A typical application is to display the point cloud corresponde...
Brown's distortion model + Linear Disparity.
static void GetKinectDefaults(BrownDistortionParameters ¶ms)
QSharedPointer< BrownDistortionParameters > Shared
Shared pointer type.
virtual DistortionModel getModel() const override
Returns distortion model type.
BrownDistortionParameters()
Default initializer.
Extended radial distortion model.
virtual DistortionModel getModel() const override
Returns distortion model type.
QSharedPointer< RadialDistortionParameters > Shared
Shared pointer type.
ExtendedRadialDistortionParameters()
Default initializer.
float k3
3rd radial distortion coefficient
Intrinsic parameters of the camera sensor.
IntrinsicParameters()
Default initializer.
static void GetKinectDefaults(IntrinsicParameters ¶ms)
float horizFocal_pix() const
Returns the horizontal focal pix.
KeyPoint()
Default constructor.
unsigned index
Index in associated point cloud.
float y
2D 'y' coordinate (in pixels)
KeyPoint(float Px, float Py, unsigned indexInCloud)
Constructor from a pixel and its index in associated cloud.
float x
2D 'x' coordinate (in pixels)
Lens distortion parameters (interface)
virtual DistortionModel getModel() const =0
Returns distortion model type.
QSharedPointer< LensDistortionParameters > Shared
Shared pointer type.
virtual ~LensDistortionParameters()
Virtual destructor.
Simple radial distortion model.
virtual DistortionModel getModel() const override
Returns distortion model type.
float k2
2nd radial distortion coefficient
RadialDistortionParameters()
Default initializer.
float k1
1st radial distortion coefficient
QSharedPointer< RadialDistortionParameters > Shared
Shared pointer type.