ImFusion SDK 4.3
FrameBasedPointCloud Class Reference

#include <ImFusion/Base/FrameBasedPointCloud.h>

Data structure for point clouds with frame-dependent point data. More...

+ Inheritance diagram for FrameBasedPointCloud:

Detailed Description

Data structure for point clouds with frame-dependent point data.

In this point cloud, all points are stored in raw form per frame, i.e. in local frame coordinates, so that when the matrix of the frame is changed, the world coordinates of the points can be easily recomputed. This is particularly useful if the points are derived from ultrasound sweeps and the calibration matrix is optimized after some segmentation.

Note
There is no mechanism to ensure that the dependent TrackedSharedImageSets are not deleted. If a TrackedSharedImageSets is removed from the data model, the associated points are removed as well.

Public Member Functions

 FrameBasedPointCloud (const std::vector< TrackedSharedImageSet * > &tsiss, std::vector< size_t > frameIndices, std::vector< vec3 > points, std::vector< vec3 > normals, std::vector< vec3 > colors, const std::string &name="")
 Constructs a new point cloud using the given TrackedSharedImageSets.
 
 FrameBasedPointCloud (const std::vector< TrackedSharedImageSet * > &tsiss, std::vector< size_t > frameIndices, std::vector< vec3 > points, std::vector< vec3 > normals, const std::string &name="")
 Constructs a new point cloud using the given TrackedSharedImageSets.
 
 FrameBasedPointCloud (const std::vector< TrackedSharedImageSet * > &tsiss, std::vector< size_t > frameIndices, std::vector< vec3 > points, const std::string &name="")
 Constructs a new point cloud using the given TrackedSharedImageSets.
 
 FrameBasedPointCloud (const std::string &name="")
 Constructs an empty frame based point cloud.
 
 FrameBasedPointCloud (const FrameBasedPointCloud &other)
 Copy constructor with another frame-based point cloud instance.
 
 FrameBasedPointCloud (FrameBasedPointCloud &&other) noexcept
 Move constructor with another point cloud instance.
 
FrameBasedPointCloudoperator= (FrameBasedPointCloud) noexcept
 Copy/Move assignment operator.
 
bool setAdditionalCalibration (const mat4 &mat, double temp)
 Sets additional spatial and temporal calibrations to consider, without modifying the calibration of m_tsiss.
 
void applyAdditionalCalibration ()
 Applies m_calibMat and m_calibTemp to all TrackedSharedImageSets and sets them to zero.
 
int removePoints (const std::vector< int > &indices) override
 Remove the points with the specified indices while keeping the point cloud consistent.
 
const std::vector< size_t > & frameIndices () const
 Returns the input frame indices.
 
const std::map< size_t, std::vector< uint32_t > > & framePoints () const
 Returns the points corresponding to their frames.
 
std::vector< vec3 > rawPoints () const
 Returns the raw points in local frame coordinates.
 
std::vector< vec3 > rawNormals () const
 Returns the raw normals in local frame coordinates.
 
const std::vector< TrackedSharedImageSet * > & trackedSharedImageSets () const
 Returns the input TrackedSharedImageSets.
 
void swapWith (FrameBasedPointCloud &other)
 Swaps the data of with other point cloud and emits a changed signal for both.
 
- Public Member Functions inherited from PointCloud
 PointCloud (int width=0, int height=0, const std::string &name="")
 Constructs an empty point cloud.
 
 PointCloud (std::vector< vec3 > points, int width=0, int height=0, const std::string &name="")
 Constructs a point cloud with the specified vertices.
 
 PointCloud (std::vector< vec3 > points, std::vector< vec3 > normals, int width=0, int height=0, const std::string &name="")
 Constructs a point cloud with the specified vertices and normals.
 
 PointCloud (std::vector< vec3 > points, std::vector< vec3 > normals, std::vector< vec3 > colors, int width=0, int height=0, const std::string &name="")
 Constructs a point cloud with the specified vertices, normals and colors.
 
 PointCloud (std::vector< vec3 > points, std::vector< vec3 > normals, std::vector< vec3 > colors, const TypedImage< int > *pixelToIndexMap, int width=0, int height=0, const std::string &name="")
 Constructs a point cloud with the specified vertices, normals, colors and mapping from pixel (x, y) to a vertex index.
 
 PointCloud (const PointCloud &other)
 Copy constructor with another point cloud instance.
 
 PointCloud (PointCloud &&other) noexcept
 Move constructor with another point cloud instance.
 
 ~PointCloud () override
 Destructor.
 
PointCloudoperator= (PointCloud) noexcept
 Copy/Move assignment operator.
 
void setMatrix (const mat4 &m) override
 Set the transformation matrix.
 
bool isAnnotationType () const override
 Return whether this data type is visualized through an annotation (e.g. mesh)
 
int size () const
 
void clear ()
 
bool isValid (bool runExtendedCheck=false) const
 Check consistency of point cloud data structure. Set runExtendedCheck to true to also check pixelToIndexMap contents (slow).
 
int width () const
 Return width.
 
void setWidth (int w)
 Set width.
 
int height () const
 Return height.
 
void setHeight (int h)
 Set height.
 
void setCameraIntrinsics (const mat3 &K)
 
mat3 cameraIntrinsics () const
 
bool isDense () const
 Return true when the point cloud is organized as an image.
 
bool isDenseCalibrated (bool reproject=false, unsigned int pixelTol=5) const
 Return true when the point cloud is organized, the intrinsics are set When 'reproject' flag is set to true, we also check that points are given in the camera coordinate system.
 
const std::vector< vec3 > & points () const
 Const access to point coordinates.
 
void setPoints (std::vector< vec3 > &&points)
 Set the points.
 
void setPoints (const std::vector< vec3 > &points)
 
bool setPoint (int idx, const vec3 &point)
 
const std::vector< vec3 > & normals () const
 Const access to normal coordinates.
 
bool setNormals (std::vector< vec3 > &&normals)
 Set the normals.
 
bool setNormals (const std::vector< vec3 > &normals)
 
bool setNormal (int idx, const vec3 &normal)
 
bool hasNormals () const
 Return true if point cloud has normals.
 
const std::vector< vec3 > & colors () const
 Const access to color coordinates.
 
bool setColors (std::vector< vec3 > &&colors)
 Set the colors.
 
bool setColors (const std::vector< vec3 > &colors)
 
bool setColor (int idx, const vec3 &color)
 
bool hasColors () const
 Return true if point cloud has colors.
 
const std::vector< double > & weights () const
 Const access to weights.
 
bool setWeights (std::vector< double > &&colors)
 Set the weights. If the size of the weight vector is not equal to the point cloud size the method does nothing and returns false. Passing in an empty vector clears the weight information.
 
bool setWeights (const std::vector< double > &colors)
 
bool setWeight (int idx, double color)
 
bool hasWeights () const
 Return true if point cloud has weights.
 
const std::vector< int > & labels () const
 Const access to labels.
 
int label (int idx) const
 Get label of the point.
 
bool setLabels (std::vector< int > &&labels)
 Set the labels.
 
bool setLabels (const std::vector< int > &labels)
 
bool setLabel (int idx, int label)
 
void requestLabels ()
 If point cloud doesn't have labels, assign zero labels to all points;.
 
void resetLabels ()
 Rest labels of all points to zero, if label information is present.
 
bool hasLabels () const
 Returns true if point cloud contains point labels.
 
PointCloudData takeData ()
 Takes all the underlying data and clears the PointCloud object.
 
MemImagelabelTexture () const
 Returns the texture image used for colors of point labels.
 
const TypedImage< int > * pixelToIndexMap () const
 Access to pixel to index map.
 
void setPixelToIndexMap (const TypedImage< int > *pixelToIndexMap)
 Set pixel to index map. Internally a copy is made.
 
void setLabelTexture (std::unique_ptr< MemImage > tex)
 Set texture for point labels. The image ownership is transferred to the point cloud class.
 
bool densePointCloudIndex (int x, int y, int &indexOut) const
 Retrieves point cloud data associated with a given pixel for dense point clouds.
 
const mat4 & matrixRef () const
 
void setFilename (const std::string &name)
 Sets a filename from where this point cloud can be loaded.
 
const std::stringfilename () const
 Returns the filename from where this point cloud can be loaded or an empty string if it's not on disk.
 
void computeBoundingBox (vec3 &origin, vec3 &extent, bool useMatrix) const
 Computes the bounding box.
 
void computeBoundingBox ()
 Compute bounding box without matrices and store results in object.
 
vec3 center ()
 Return bounding box center computed by a previous call to computeBoundingBox.
 
vec3 origin ()
 Return bounding box origin computed by a previous call to computeBoundingBox.
 
vec3 extent ()
 Return bounding box extent computed by a previous call to computeBoundingBox.
 
int duplicatePoints (const std::vector< int > &indices)
 Duplicate the point with the specified indices while keeping the point cloud consistent. Invalidates m_pixelToIndexMap.
 
void beginUpdate ()
 After this call no signals will be emitted if the point cloud data is changed.
 
void endUpdate ()
 End update and send point cloud changed signal.
 
bool signalsBlocked () const
 Returns true if the signals are blocked.
 
void transformPointCloud (const mat4 &transformation)
 Apply given matrix to point cloud.
 
void convertColorsToLabels (const std::vector< std::pair< vec3, int > > *colorToLabelMap=nullptr, double channelTol=0.1)
 Resets point cloud labels.
 
void swapWith (PointCloud &other)
 Swaps the data of with other point cloud and emits a changed signal for both.
 
Kind kind () const override
 Return the kind of this data.
 
Geometry::AlignedBox bounds () const override
 Returns the axis-aligned bounding box of this data in world space.
 
Geometry::AlignedBox boundsLocal ()
 Returns the axis-aligned bounding box of this data in local space.
 
Pose::TransformationConvention matrixConvention () const override
 Matrices of point clouds map to world coordinate system.
 
- Public Member Functions inherited from Data
 Data (const std::string &name="")
 
 Data (const Data &other)
 
Dataoperator= (const Data &other)
 
virtual ~Data ()
 Mandatory virtual destructor.
 
virtual Modality modality () const
 Return the modality of this data.
 
const std::stringname () const
 Return the name of this data.
 
void setName (const std::string &name)
 Sets the name of this data.
 
const DataComponentListcomponents () const
 Returns the list of DataComponents for this data.
 
DataComponentListcomponents ()
 
virtual std::string describe () const
 Human readable description of the data for showing in the info bar.
 
virtual void setMatrixFromWorld (const mat4 &m)
 Set matrix mapping from the world coordinate system to the data coordinate system.
 
virtual void setMatrixToWorld (const mat4 &m)
 Set matrix mapping from the data coordinate system to the world coordinate system.
 
virtual mat4 matrixFromWorld () const
 Get matrix mapping from the world coordinate system to the data coordinate system.
 
virtual mat4 matrixToWorld () const
 Get matrix mapping from the data coordinate system to the world coordinate system.
 
virtual mat4 matrix () const
 Return the transformation matrix.
 
- Public Member Functions inherited from SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (SignalReceiver rhs)
 Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs.
 
virtual ~SignalReceiver ()
 Virtual destructor disconnects from all connected signals.
 

Protected Types

typedef std::pair< TrackedSharedImageSet *, int > FrameId
 

Protected Member Functions

void initialize (bool computePixelCoordinates=true)
 Called in constructor. Sets up signals and runs the first point computation.
 
void trackingSequenceUpdated ()
 Recomputes points if not suspended and emits point cloud changed signal.
 
void recomputePoints ()
 Recomputes the point cloud representation using the frame matrices in m_tsiss, taking m_calibMat and m_calibTemp into account.
 
void deleteFramePoints (TrackedSharedImageSet *tsis, int frameIdx)
 Delete points of specified frame index. All points are deleted if frame index is -1.
 
- Protected Member Functions inherited from PointCloud
void emitPointCloudChangedSignal ()
 
void createDefaultLabelTexture (int numLabels)
 Create a default texture for point labels. Size of the texture is defined by input parameter 'numLabels'.
 
- Protected Member Functions inherited from Data
void swapWith (Data &other)
 Swaps the data and emits a matrix and name changed signal for both.
 
- Protected Member Functions inherited from SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 

Protected Attributes

std::vector< size_t > m_frameIndices
 Index assigning each point to a TrackedSharedImageSet (4th byte) and a frame therein (bytes 1-3).
 
std::vector< vec3 > m_rawPoints
 Points in local frame coordinates (internally stored in pixel coordinates)
 
std::vector< vec3 > m_rawNormals
 Normals in local frame coordinates (internally stored in pixel coordinates)
 
std::vector< TrackedSharedImageSet * > m_tsiss
 TrackedSharedImageSets containing the frames m_frameIndices map to.
 
std::vector< std::shared_ptr< SignalConnection > > m_trackingChangedSignalConnections
 Connections to signal when used tracking changed.
 
std::unordered_map< const SharedImage *, FrameIdm_imageToFrameId
 Look-up table to associate deletion signal of a SharedImage to the TrackedSharedImageSet and the frame index therein.
 
std::map< size_t, std::vector< uint32_t > > m_frameToPointsIndices
 
- Protected Attributes inherited from PointCloud
std::vector< vec3 > m_points
 point cloud vertices
 
std::vector< vec3 > m_normals
 point cloud vertex normals
 
std::vector< vec3 > m_colors
 point cloud vertex colors
 
std::vector< int > m_labels
 point cloud vertex labels
 
std::vector< double > m_weights
 
std::unique_ptr< TypedImage< int > > m_pixelToIndexMap
 
int m_width
 width of the point cloud. In case of non-dense point clouds it should be equal to the number of vertices
 
int m_height
 height of the point cloud. In case of non-dense point clouds it should be equal to 1
 
mat3 m_K
 
std::string m_filename
 the path from where the point cloud was loaded or empty if not loaded from file
 
bool m_updateBoundingBox
 
vec3 m_origin
 
vec3 m_extent
 
bool m_updateBoundingBoxWithMatrix
 axis-aligned bounding box of this data in world space
 
Geometry::AlignedBox m_boundingBoxWithMatrix
 flag which indicates whether the bounds of this data should be re-computed
 
std::unique_ptr< MemImagem_labelTexture
 
- Protected Attributes inherited from Data
mat4 m_matrix
 Transformation matrix.
 
std::recursive_mutexm_matrixMutex
 Used to internally synchronize access to the matrix of data.
 
DataComponentList m_dataComponentList
 The list of DataComponents for this data.
 

Additional Inherited Members

- Public Types inherited from Data
enum  Kind {
  UNKNOWN = 0 , IMAGE = 1 , VOLUME = 2 , IMAGESET = 3 ,
  VOLUMESET = 4 , IMAGESTREAM = 5 , VOLUMESTREAM = 6 , POINTSET = 7 ,
  SURFACE = 8 , TRACKINGSTREAM = 9 , LIVETRACKINGSTREAM = TRACKINGSTREAM , TRACKINGDATA = 10 ,
  TREE = 11 , TENSOR = 12 , POLYDATASTREAM = 13 , STEREOIMAGESET = 14 ,
  STEREOIMAGESTREAM = 15 , VOLUMETRICMESH = 16
}
 Kind of data. More...
 
enum  Modality {
  NA = 0 , XRAY = 1 , CT = 2 , MRI = 3 ,
  ULTRASOUND = 4 , VIDEO = 5 , NM = 6 , OCT = 7 ,
  LABEL = 8 , DISTANCE = 9
}
 Image modality of the data. More...
 
- Static Public Member Functions inherited from PointCloud
static bool convertFromPCL (PointCloud *&pcOut, const pcl::PCLPointCloud2 &headerIn, const std::string &nameIn="", bool ignoreNanPoints=true, int versionImFusion=-1)
 Convert PClPointCloud2 to PointCloud.
 
static bool convertToPCL (pcl::PCLPointCloud2 &headerOut, std::string &nameOut, const PointCloud *pcIn, bool applyMatrix)
 Convert PointCloud to PClPointCloud2.
 
- Static Public Member Functions inherited from Data
static std::string modalityString (Data::Modality m)
 Return the name of an image modality.
 
static Data::Modality stringToModality (const std::string &s)
 Returns the modality corresponding to a modality string or NA if nothing matches.
 
- Public Attributes inherited from PointCloud
Signal signalPointCloudChanged
 Signal emitted when the point cloud data has changed.
 
- Public Attributes inherited from Data
Signal< const Data * > signalDeleted
 Signal emitted when this instance is deleted.
 
Signal< const Data * > signalMatrixChanged
 Signal emitted when the transformation of this Data has changed.
 
Signal< std::stringsignalNameChanged
 Signal emitted when the name changed.
 

Constructor & Destructor Documentation

◆ FrameBasedPointCloud() [1/3]

FrameBasedPointCloud ( const std::vector< TrackedSharedImageSet * > & tsiss,
std::vector< size_t > frameIndices,
std::vector< vec3 > points,
std::vector< vec3 > normals,
std::vector< vec3 > colors,
const std::string & name = "" )

Constructs a new point cloud using the given TrackedSharedImageSets.

Provide points and normals untransformed, i.e. in local frame coordinates. The transformation will be applied automatically.

Note
The frame indices encode the index of the frame within a TrackedSharedImageSet (bytes 1-3) and the TrackedSharedImageSet itself (1 byte representing the position in the vector).

Example: A frame index of 0x010000ff refers to the image at position 255 of the TrackedSharedImageSet at position 1 in the vector tsiss.

◆ FrameBasedPointCloud() [2/3]

FrameBasedPointCloud ( const std::vector< TrackedSharedImageSet * > & tsiss,
std::vector< size_t > frameIndices,
std::vector< vec3 > points,
std::vector< vec3 > normals,
const std::string & name = "" )

Constructs a new point cloud using the given TrackedSharedImageSets.

Provide points and normals untransformed, i.e. in local frame coordinates. The transformation will be applied automatically.

◆ FrameBasedPointCloud() [3/3]

FrameBasedPointCloud ( const std::vector< TrackedSharedImageSet * > & tsiss,
std::vector< size_t > frameIndices,
std::vector< vec3 > points,
const std::string & name = "" )

Constructs a new point cloud using the given TrackedSharedImageSets.

Provide points untransformed, i.e. in local frame coordinates. The transformation will be applied automatically.

Member Function Documentation

◆ setAdditionalCalibration()

bool setAdditionalCalibration ( const mat4 & mat,
double temp )

Sets additional spatial and temporal calibrations to consider, without modifying the calibration of m_tsiss.

A standard use case would be the opimization of the calibration matrix, where only the optimal calibration should be applied at the end. Will call recomputePoints if any of the two has changed.

Returns
True if points were recomputed.

◆ applyAdditionalCalibration()

void applyAdditionalCalibration ( )

Applies m_calibMat and m_calibTemp to all TrackedSharedImageSets and sets them to zero.

Because this operation does not cause any point to move its position, recomputePoints is not called.

◆ removePoints()

int removePoints ( const std::vector< int > & indices)
overridevirtual

Remove the points with the specified indices while keeping the point cloud consistent.

Reimplemented from PointCloud.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close