12 #pragma warning(disable : 4250)
25 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
26 #include <QOpenGLBuffer>
27 #define QGLBuffer QOpenGLBuffer
47 #ifdef CV_RANSAC_SUPPORT
51 enum RANSAC_PRIMITIVE_TYPES {
62 unsigned supportPoints;
64 float maxNormalDev_deg;
70 std::vector<RANSAC_PRIMITIVE_TYPES> primEnabled;
77 maxNormalDev_deg(25.0f),
80 minRadius(0.0000001f),
81 maxRadius(1000000.0f) {
82 primEnabled.push_back(RPT_PLANE);
83 primEnabled.push_back(RPT_SPHERE);
84 primEnabled.push_back(RPT_CYLINDER);
87 RansacParams(
float scale)
88 : epsilon(0.005f * scale),
89 bitmapEpsilon(0.01f * scale),
91 maxNormalDev_deg(25.0f),
94 minRadius(0.0000001f),
95 maxRadius(1000000.0f) {
96 primEnabled.push_back(RPT_PLANE);
97 primEnabled.push_back(RPT_SPHERE);
98 primEnabled.push_back(RPT_CYLINDER);
104 std::string getTypeName()
const;
105 unsigned getDrawingPrecision()
const;
106 bool setDrawingPrecision(
unsigned steps);
109 std::vector<size_t> indices;
110 std::shared_ptr<ccGenericPrimitive> primitive =
nullptr;
113 using RansacResults = std::vector<RansacResult>;
119 class PinholeCameraIntrinsic;
129 #if defined(CV_ENV_32)
161 const
std::
string&
name = "cloud");
204 const std::vector<size_t>& indices,
205 bool invert =
false);
209 WRN_OUT_OF_MEM_FOR_COLORS = 1,
210 WRN_OUT_OF_MEM_FOR_NORMALS = 2,
211 WRN_OUT_OF_MEM_FOR_SFS = 4,
212 WRN_OUT_OF_MEM_FOR_FWF = 8
227 int* warnings =
nullptr,
228 bool withChildEntities =
true)
const;
238 bool ignoreChildren =
false);
242 bool ignoreChildren =
false)
override;
260 void clear()
override;
266 void unalloactePoints();
269 void unallocateColors();
272 void unallocateNorms();
277 m_vboManager.updateFlags |= vboSet::UPDATE_COLORS;
281 m_vboManager.updateFlags |= vboSet::UPDATE_NORMALS;
285 m_vboManager.updateFlags |= vboSet::UPDATE_POINTS;
294 bool reserve(
unsigned numberOfPoints)
override;
304 bool reserveThePointsTable(
unsigned _numberOfPoints);
314 bool reserveTheRGBTable();
324 bool reserveTheNormsTable();
332 bool resize(
unsigned numberOfPoints)
override;
344 bool resizeTheRGBTable(
bool fillWithWhite =
false);
354 bool resizeTheNormsTable();
358 if (
size() < capacity()) resize(
size());
365 int getCurrentDisplayedScalarFieldIndex()
const;
369 void setCurrentDisplayedScalarField(
int index);
372 void deleteScalarField(
int index)
override;
373 void deleteAllScalarFields()
override;
374 int addScalarField(
const char* uniqueName)
override;
377 bool sfColorScaleShown()
const;
379 void showSFColorsScale(
bool state);
396 bool init(
unsigned rowCount,
unsigned colCount,
bool withRGB =
false);
399 void setIndex(
unsigned row,
unsigned col,
int index);
405 void updateMinAndMaxValidIndexes();
408 QImage toImage()
const;
412 bool toFile(QFile& out,
short dataVersion)
const override;
413 bool fromFile(QFile& in,
417 short minimumFileVersion()
const override;
446 return m_grids[gridIndex];
451 m_grids.push_back(grid);
452 }
catch (
const std::bad_alloc&) {
463 ccMesh* triangulateGrid(
const Grid& grid,
464 double minTriangleAngle_deg = 0.0)
const;
470 bool computeNormalsWithGrids(
double minTriangleAngle_deg = 1.0,
477 bool orientNormalsTowardViewPoint(
CCVector3& VP,
481 bool computeNormalsWithOctree(
488 bool orientNormalsWithMST(
unsigned kNN = 6,
492 bool orientNormalsWithFM(
unsigned char level,
515 std::vector<ccWaveform>&
waveforms() {
return m_fwfWaveforms; }
517 const std::vector<ccWaveform>&
waveforms()
const {
return m_fwfWaveforms; }
520 bool reserveTheFWFTable();
522 bool resizeTheFWFTable();
533 bool compressFWFData();
536 bool computeFWFAmplitude(
double& minVal,
550 void invalidateBoundingBox()
override;
553 void getDrawingParameters(
glDrawParams& params)
const override;
554 unsigned getUniqueIDForDisplay()
const override;
557 bool hasColors()
const override;
558 bool hasNormals()
const override;
559 bool hasScalarFields()
const override;
560 bool hasDisplayedScalarField()
const override;
563 unsigned char testVisibility(
const CCVector3& P)
const override;
567 const CCVector3* getNormal(
unsigned pointIndex)
const
571 const ecvColor::Rgb* getScalarValueColor(ScalarType d)
const override;
573 unsigned pointIndex)
const override;
574 ScalarType getPointDisplayedDistance(
unsigned pointIndex)
const override;
576 const ecvColor::Rgb& getPointColor(
unsigned pointIndex)
const override;
579 Eigen::Vector3d getEigenColor(
size_t index)
const;
580 std::vector<Eigen::Vector3d> getEigenColors()
const;
581 void setEigenColors(
const std::vector<Eigen::Vector3d>&
colors);
584 unsigned pointIndex)
const override;
585 const CCVector3& getPointNormal(
unsigned pointIndex)
const override;
586 CCVector3& getPointNormalPtr(
size_t pointIndex)
const;
587 std::vector<CCVector3> getPointNormals()
const;
588 std::vector<CCVector3*> getPointNormalsPtr()
const;
589 void setPointNormals(
const std::vector<CCVector3>&
normals);
590 Eigen::Vector3d getEigenNormal(
size_t index)
const;
591 std::vector<Eigen::Vector3d> getEigenNormals()
const;
592 void setEigenNormals(
const std::vector<Eigen::Vector3d>&
normals);
595 bool inside =
true)
override;
598 virtual void applyRigidTransformation(
const ccGLMatrix& trans)
override;
603 inline void refreshBB()
override { invalidateBoundingBox(); }
607 bool removeSelectedPoints =
false,
608 VisibilityTableType* visTable =
nullptr,
609 std::vector<int>* newIndexesOfRemainingPoints =
nullptr,
612 bool removeVisiblePoints(VisibilityTableType* visTable =
nullptr,
613 std::vector<int>* newIndexes =
nullptr)
override;
619 m_visibilityCheckEnabled = state;
623 bool hasSensor()
const;
629 QSharedPointer<cloudViewer::ReferenceCloud> computeCPSet(
635 bool interpolateColorsFrom(
643 void setPointColor(
size_t pointIndex,
const ecvColor::Rgb& col);
645 void setPointColor(
size_t pointIndex,
const Eigen::Vector3d& col);
646 void setEigenColor(
size_t index,
const Eigen::Vector3d&
color);
657 void setPointNormal(
size_t pointIndex,
const CCVector3& N);
658 void setEigenNormal(
size_t index,
const Eigen::Vector3d&
normal);
669 void addEigenNorm(
const Eigen::Vector3d& N);
670 void addEigenNorms(
const std::vector<Eigen::Vector3d>&
normals);
672 void addNorms(
const std::vector<CCVector3>& Ns);
673 void addNorms(
const std::vector<CompressedNormType>& idxes);
674 std::vector<CompressedNormType> getNorms()
const;
675 void getNorms(std::vector<CompressedNormType>& idxes)
const;
691 bool convertNormalToRGB();
705 void addRGBColors(
const std::vector<ecvColor::Rgb>&
colors);
706 void addEigenColor(
const Eigen::Vector3d&
color);
707 void addEigenColors(
const std::vector<Eigen::Vector3d>&
colors);
729 bool convertRGBToGreyScale();
739 bool colorize(
float r,
float g,
float b);
748 bool setRGBColorByHeight(
unsigned char heightDim,
758 bool setRGBColorByBanding(
unsigned char dim,
double freq);
764 bool convertCurrentScalarFieldToColors(
bool mixWithExistingColor =
false);
769 bool setRGBColorWithCurrentScalarField(
bool mixWithExistingColor =
false);
794 bool applyToSFduringRGB =
false;
796 unsigned char burntOutColorThreshold = 0;
797 bool commandLine =
false;
799 double spatialSigma = -1;
800 bool blendGrayscale =
false;
801 unsigned char blendGrayscaleThreshold = 0;
802 double blendGrayscalePercent = 0.5;
823 bool applyFilterToRGB(
838 ccPointCloud* filterPointsByScalarValue(ScalarType minVal,
840 bool outside =
false);
848 ccPointCloud* filterPointsByScalarValue(std::vector<ScalarType> values,
849 bool outside =
false);
856 void hidePointsByScalarValue(ScalarType minVal, ScalarType maxVal);
862 void hidePointsByScalarValue(std::vector<ScalarType> values);
867 STRAIGHTENED_CONE = 2,
868 STRAIGHTENED_CONE2 = 3
898 bool exportDeviationSF =
false,
899 double startAngle_deg = 0.0,
900 double stopAngle_deg = 360.0,
928 unsigned char orthoDim,
939 unsigned pointCountBefore,
940 bool ignoreChildren =
false);
944 bool enhanceRGBWithIntensitySF(
int sfIdx,
945 bool useCustomIntensityRange =
false,
953 bool setCoordFromSF(
bool importDims[3],
961 inline virtual bool IsEmpty()
const override {
return !hasPoints(); }
970 inline virtual Eigen::Vector3d
GetCenter()
const override {
974 virtual ccBBox GetAxisAlignedBoundingBox()
const override;
977 virtual ccPointCloud& Translate(
const Eigen::Vector3d& translation,
978 bool relative =
true)
override;
983 const Eigen::Vector3d& center)
override;
985 const Eigen::Vector3d& center)
override;
989 return !m_points.empty() && covariances_.size() == m_points.size();
1003 const std::vector<size_t>& indices,
bool invert =
false)
const;
1012 ccPointCloud& RemoveNonFinitePoints(
bool remove_nan =
true,
1013 bool remove_infinite =
true);
1034 std::tuple<std::shared_ptr<ccPointCloud>,
1036 std::vector<std::vector<int>>>
1038 const Eigen::Vector3d& min_bound,
1039 const Eigen::Vector3d& max_bound,
1040 bool approximate_class =
false)
const;
1051 size_t every_k_points)
const;
1061 std::shared_ptr<ccPointCloud> RandomDownSample(
double sampling_ratio)
const;
1071 std::shared_ptr<ccPointCloud> FarthestPointDownSample(
1072 const size_t num_samples,
const size_t start_index = 0)
const;
1080 std::shared_ptr<ccPointCloud> Crop(
const ccBBox& bbox)
const;
1088 std::shared_ptr<ccPointCloud> Crop(
const ecvOrientedBBox& bbox)
const;
1095 std::tuple<std::shared_ptr<ccPointCloud>, std::vector<size_t>>
1103 std::tuple<std::shared_ptr<ccPointCloud>, std::vector<size_t>>
1118 bool fast_normal_computation =
true);
1124 bool OrientNormalsToAlignWithDirection(
1125 const Eigen::Vector3d& orientation_reference =
1126 Eigen::Vector3d(0.0, 0.0, 1.0));
1132 bool OrientNormalsTowardsCameraLocation(
1133 const Eigen::Vector3d& camera_location = Eigen::Vector3d::Zero());
1141 void OrientNormalsConsistentTangentPlane(
size_t k);
1150 std::vector<double> ComputePointCloudDistance(
const ccPointCloud& target);
1159 static std::vector<Eigen::Matrix3d> EstimatePerPointCovariances(
1170 void EstimateCovariances(
1178 std::vector<double> ComputeMahalanobisDistance()
const;
1182 std::vector<double> ComputeNearestNeighborDistance()
const;
1184 double ComputeResolution()
const;
1187 std::tuple<std::shared_ptr<ccMesh>, std::vector<size_t>> ComputeConvexHull()
1199 std::tuple<std::shared_ptr<ccMesh>, std::vector<size_t>> HiddenPointRemoval(
1200 const Eigen::Vector3d& camera_location,
const double radius)
const;
1213 std::vector<int> ClusterDBSCAN(
double eps,
1215 bool print_progress =
false)
const;
1217 #ifdef CV_RANSAC_SUPPORT
1230 cloudViewer::geometry::RansacResults ExecuteRANSAC(
1231 const cloudViewer::geometry::RansacParams& params =
1232 cloudViewer::geometry::RansacParams(),
1233 bool print_progress =
false);
1245 std::tuple<Eigen::Vector4d, std::vector<size_t>> SegmentPlane(
1246 const double distance_threshold = 0.01,
1247 const int ransac_n = 3,
1248 const int num_iterations = 100)
const;
1269 static std::shared_ptr<ccPointCloud> CreateFromDepthImage(
1272 const Eigen::Matrix4d& extrinsic = Eigen::Matrix4d::Identity(),
1273 double depth_scale = 1000.0,
1274 double depth_trunc = 1000.0,
1276 bool project_valid_depth_only =
true);
1294 static std::shared_ptr<ccPointCloud> CreateFromRGBDImage(
1297 const Eigen::Matrix4d& extrinsic = Eigen::Matrix4d::Identity(),
1298 bool project_valid_depth_only =
true);
1306 std::shared_ptr<ccPointCloud> CreateFromVoxelGrid(
1321 void applyGLTransformation(
const ccGLMatrix& trans)
override;
1322 bool toFile_MeOnly(QFile& out,
short dataVersion)
const override;
1323 short minimumFileVersion_MeOnly()
const override;
1324 bool fromFile_MeOnly(QFile& in,
1328 void notifyGeometryUpdate()
override;
1333 void swapPoints(
unsigned firstIndex,
unsigned secondIndex)
override;
1335 virtual void removePoints(
size_t index)
override;
1375 bool* reallocated =
nullptr);
1391 UPDATE_ALL = UPDATE_POINTS | UPDATE_COLORS | UPDATE_NORMALS
1399 totalMemSizeBytes(0),
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
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
Array of RGB colors for each point.
Array of compressed 3D normals (single index)
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
static std::vector< Eigen::Matrix< double, 3, 1 > > fromArrayContainer(const std::vector< Vector3Tpl< PointCoordinateType >> &container)
QSharedPointer< ccColorScale > Shared
Shared pointer type.
Float version of ccGLMatrixTpl.
Double version of ccGLMatrixTpl.
A 3D cloud interface with associated features (color, normals, octree, etc.)
Generic primitive interface.
Orientation
'Default' orientations
L.O.D. (Level of Detail) structure.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
void enableVisibilityCheck(bool state)
bool normalsAvailable() const override
Returns whether normals are available.
const Grid::Shared & grid(size_t gridIndex) const
Returns an associated grid (const verson)
ccScalarField * m_currentDisplayedScalarField
Currently displayed scalar field.
std::vector< ccWaveform > m_fwfWaveforms
Per-point waveform accessors.
vboSet m_vboManager
Set of VBOs attached to this cloud.
bool m_sfColorScaleDisplayed
ColorsTableType * rgbColors() const
Returns pointer on RGB colors table.
QMap< uint8_t, WaveformDescriptor > FWFDescriptorSet
Waveform descriptors set.
const FWFDescriptorSet & fwfDescriptors() const
Gives access to the FWF descriptors (const version)
NormsIndexesTableType * m_normals
Normals (compressed)
void refreshBB() override
Forces bounding-box update.
bool HasCovariances() const
Returns 'true' if the point cloud contains per-point covariance matrix.
ccPointCloudLOD * m_lod
L.O.D. structure.
FWFDescriptorSet & fwfDescriptors()
Gives access to the FWF descriptors.
ccPointCloud & Translate(const CCVector3 &T)
NormsIndexesTableType * normals() const
Returns pointer on compressed normals indexes table.
std::vector< ccWaveform > & waveforms()
Gives access to the associated FWF data.
QSharedPointer< const FWFDataContainer > SharedFWFDataContainer
virtual bool IsEmpty() const override
void normalsHaveChanged()
Notify a modification of normals display parameters or contents.
int m_currentDisplayedScalarFieldIndex
Currently displayed scalar field index.
void addGreyColor(ColorCompType g)
Pushes a grey color on stack (shortcut)
const ColorsTableType & getPointColors() const
void pointsHaveChanged()
Notify a modification of points display parameters or contents.
virtual Eigen::Vector3d GetMinBound() const override
Returns min bounds for geometry coordinates.
RGB_FILTER_TYPES
RGB filter types.
bool m_visibilityCheckEnabled
Whether visibility check is available or not (during comparison)
virtual Eigen::Vector3d GetCenter() const override
Returns the center of the geometry coordinates.
ccPointCloud operator+(const ccPointCloud &cloud) const
std::vector< uint8_t > FWFDataContainer
Waveform data container.
std::vector< Grid::Shared > m_grids
Associated grid structure.
bool addGrid(Grid::Shared grid)
Adds an associated grid.
void removeGrids()
Remove all associated grids.
const SharedFWFDataContainer & fwfData() const
Gives access to the associated FWF data container (const version)
SharedFWFDataContainer & fwfData()
Gives access to the associated FWF data container.
ColorsTableType * m_rgbColors
Colors.
SharedFWFDataContainer m_fwfData
Waveforms raw data storage.
Grid::Shared & grid(size_t gridIndex)
Returns an associated grid.
std::vector< Eigen::Matrix3d > covariances_
Covariance Matrix for each point.
void shrinkToFit()
Removes unused capacity.
FWFDescriptorSet m_fwfDescriptors
General waveform descriptors.
virtual Eigen::Vector3d GetMaxBound() const override
Returns max bounds for geometry coordinates.
bool setRGBColor(ColorCompType r, ColorCompType g, ColorCompType b)
Set a unique color for the whole cloud (shortcut)
const std::vector< ccWaveform > & waveforms() const
Gives access to the associated FWF data (const version)
void addRGBColor(ColorCompType r, ColorCompType g, ColorCompType b)
Pushes an RGB color on stack (shortcut)
CLONE_WARNINGS
Warnings for the partialClone method (bit flags)
size_t gridCount() const
Returns the number of associated grids.
A scalar field associated to display-related parameters.
Serializable object interface.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
A generic 3D point cloud with index-based point access.
A very simple point cloud (no point duplication)
A simple scalar field (to be associated to a point cloud)
Contains the pinhole camera intrinsic parameters.
The Image class stores image with customizable width, height, num of channels and bytes per channel.
KDTree search parameters for pure KNN search.
Base class for KDTree search parameters.
RGBDImage is for a pair of registered color and depth images,.
VoxelGrid is a collection of voxels which are aligned in grid.
Graphical progress indicator (thread-safe)
unsigned int CompressedNormType
Compressed normals type.
unsigned char ColorCompType
Default color components type (R,G and B)
const unsigned CC_MAX_NUMBER_OF_POINTS_PER_CLOUD
bool exportNormalToSF(const ccHObject::Container &selectedEntities, QWidget *parent, bool *exportDimensions)
bool invertNormals(const ccHObject::Container &selectedEntities)
bool exportCoordToSF(const ccHObject::Container &selectedEntities, QWidget *parent)
bool setColor(ccHObject::Container selectedEntities, bool colorize, QWidget *parent)
void RemoveStatisticalOutliers(benchmark::State &state, const core::Device &device, const int nb_neighbors)
void UniformDownSample(benchmark::State &state, const core::Device &device, size_t k)
void SelectByIndex(benchmark::State &state, bool remove_duplicates, const core::Device &device)
void VoxelDownSample(benchmark::State &state, const core::Device &device, float voxel_size, const std::string &reduction)
void RemoveRadiusOutliers(benchmark::State &state, const core::Device &device, const int nb_points, const double search_radius)
void Transform(benchmark::State &state, const core::Device &device)
void EstimateNormals(benchmark::State &state, const core::Device &device, const core::Dtype &dtype, const double voxel_size, const utility::optional< int > max_nn, const utility::optional< double > radius)
void operator+=(MiniVec< T, N > &a, const MiniVec< T, N > &b)
Generic file read and write utility for python interface.
unsigned validCount
Number of valid indexes.
unsigned minValidIndex
Minimum valid index.
std::vector< ecvColor::Rgb > colors
Grid colors (size: w x h, or 0 = no color)
ccGLMatrixd sensorPosition
Sensor position (expressed relatively to the cloud points)
unsigned maxValidIndex
Maximum valid index.
std::vector< int > indexes
Grid indexes (size: w x h)
Grid(const Grid &grid)=default
Copy constructor.
bool isSerializable() const override
Returns whether object is serializable of not.
QSharedPointer< Grid > Shared
Shared type.
PointCoordinateType radius
unrolling cylinder radius (or cone base radius)
unsigned char axisDim
unrolling cylinder/cone axis (X=0, Y=1 or Z=2)
double coneAngle_deg
Cone apex.
STATES state
Current state.
STATES
States of the VBO(s)
UPDATE_FLAGS
Update flags.
std::vector< VBO * > vbos
Display parameters of a 3D entity.