CVB++ 15.1
Loading...
Searching...
No Matches
decl_point_cloud.hpp
1#pragma once
2
3#include <limits>
4#include <type_traits>
5#include <unordered_map>
6
7#include "../_cexports/c_core_3d.h"
8
9#include "decl_composite.hpp"
10
11#include "../affine_matrix_3d.hpp"
12#include "../cuboid.hpp"
13#include "../data_type.hpp"
14#include "../exception.hpp"
15#include "../global.hpp"
16#include "../image.hpp"
17#include "../matrix_3d.hpp"
18#include "../matrix_3d_h.hpp"
19#include "../point_3d.hpp"
20#include "../point_3d_h.hpp"
21#include "../size_2d.hpp"
22#include "../plane.hpp"
23#include "../utilities/system_info.hpp"
24#include "../components_pointers_3d.hpp"
25
26#include "../plane_3d.hpp"
27
28#include "../calibrator_3d.hpp"
29#include "../core_3d.hpp"
30
31namespace Cvb
32{
33
34 CVB_BEGIN_INLINE_NS
35
36 namespace detail
37 {
38 // Backport std::is_invocable_r for C++14
39 template <typename R, typename F, typename... Args>
40 struct is_invocable_r
41 : std::is_constructible<std::function<R(Args...)>,
42 std::reference_wrapper<typename std::remove_reference<F>::type>>
43 {
44 };
45 } // namespace detail
46
47 template <>
48 inline HandleGuard<PointCloud>::HandleGuard(void *handle) noexcept
49 : HandleGuard<PointCloud>(handle, [](void *handle) { CVB_CALL_CAPI(ReleaseObject(handle)); })
50 {
51 }
52
73 class PointCloud
74 {
75 private:
76 template <class Point>
77 static PointCloudFlags PointTypeToFlags()
78 {
79 if (std::is_same<Point, Cvb::Point3D<float>>::value)
81 else if (std::is_same<Point, Cvb::Point3D<double>>::value)
83 else if (std::is_same<Point, Cvb::Point3DC<float>>::value)
85 else if (std::is_same<Point, Cvb::Point3DC<double>>::value)
87 else if (std::is_same<Point, Cvb::Point3DH<float>>::value)
89 else if (std::is_same<Point, Cvb::Point3DH<double>>::value)
91 else
92 throw std::invalid_argument("Point must be one of the Cvb::Point3D types.");
93 }
94
95 protected:
96 struct PrivateTag
97 {
98 };
99
100 public:
101 using GuardType = HandleGuard<PointCloud>;
102
104
111 static PointCloudPtr FromHandle(HandleGuard<PointCloud> &&guard);
112
113 template <class T>
114 static std::shared_ptr<T> FromHandle(HandleGuard<PointCloud> &&guard)
115 {
116 // required for generic object creation
117 return T::FromHandle(std::move(guard));
118 }
119
121
126 template <class T>
128
130
146 static PointCloudPtr FromMemory(void *buffer, size_t size, PointCloudFlags flags, Cvb::PointCloudFileFormat format);
147
149
165 template <class Point>
166 static PointCloudPtr FromMemory(void *buffer, size_t size, Cvb::PointCloudFileFormat format)
167 {
168 auto flags = PointTypeToFlags<Point>();
169 return FromMemory(buffer, size, flags, format);
170 }
171
173
178 {
179 CExports::CVC3DPointCloudLayout layout = CExports::CVC3DPCL_Invalid;
180 Internal::DoResCall([&]() { return CVB_CALL_CAPI(CVC3DPointCloudAnalyzeLayout(Handle(), layout)); });
181 return static_cast<PointCloudLayout>(layout);
182 }
183
185
189 class DataType DataType() const
190 {
191 CExports::cvbdatatype_t dt = 0;
192 Internal::DoResCall([&]() { return CVB_CALL_CAPI(CVC3DPointCloudGetDatatype(Handle(), dt)); });
193 return Cvb::DataType::FromNativeDescriptor(static_cast<int>(dt));
194 }
195
197
202 {
203 CExports::cvbint64_t numPoints = 0;
204 Internal::DoResCall([&]() { return CVB_CALL_CAPI(CVC3DPointCloudGetNumPoints(Handle(), numPoints)); });
205 return static_cast<std::size_t>(numPoints);
206 }
207
209
214 {
215 ComponentsPointers3D components;
216 auto error = TryPointComponents(components);
217 if (error)
219 return components;
220 }
221
223
228 template <class T>
230 {
231 return PointsTyped(points);
232 }
233
235
240 template <class T>
242 {
243 return PointsHTyped(pointsH);
244 }
245
247
254 Cuboid CalculateBoundingBox(bool onlyConfidentPoints = true) const
255 {
256 if (onlyConfidentPoints)
257 {
258 for (const auto p : Planes())
259 {
260 if (p->Role() == PlaneRole::PixConfidence)
261 return CalculateBoundingBox([](double confidence) {
262 return std::fabs(confidence - 1.0) <= std::numeric_limits<double>::epsilon();
263 });
264 }
265 }
266
267 Cuboid boundingBox;
268 Internal::DoResCall([&]() {
269 return CVB_CALL_CAPI(
270 CVC3DPointCloudCalculateBoundingBox(Handle(), *reinterpret_cast<CExports::CVC3DCuboid *>(&boundingBox)));
271 });
272 return boundingBox;
273 }
274
277
289 template <typename FN,
290 typename std::enable_if_t<detail::is_invocable_r<bool, FN, double, double, double>::value> * = nullptr>
291 Cuboid CalculateBoundingBox(const FN &xyzPredicate) const
292 {
293 using FNType = typename std::conditional<std::is_function<FN>::value, FN, typename std::add_const<FN>::type>::type;
294 thread_local FNType *fn = nullptr;
295 auto predicate = [](double x, double y, double z) -> bool { return (*fn)(x, y, z); };
296
297 fn = &xyzPredicate;
298
299 Cuboid boundingBox;
300 Internal::DoResCall([&]() {
301 return CVB_CALL_CAPI(CVC3DPointCloudCalculateBoundingBoxFiltered(
302 Handle(), predicate, *reinterpret_cast<CExports::CVC3DCuboid *>(&boundingBox)));
303 });
304
305 return boundingBox;
306 }
307
310
322 template <typename FN, typename std::enable_if_t<detail::is_invocable_r<bool, FN, double>::value> * = nullptr>
323 Cuboid CalculateBoundingBox(const FN &confidencePredicate) const
324 {
325 using FNType = typename std::conditional<std::is_function<FN>::value, FN, typename std::add_const<FN>::type>::type;
326 thread_local FNType *fn = nullptr;
327 auto predicate = [](double c) -> bool { return (*fn)(c); };
328
329 fn = &confidencePredicate;
330
331 Cuboid boundingBox;
332 Internal::DoResCall([&]() {
333 return CVB_CALL_CAPI(CVC3DPointCloudCalculateBoundingBoxFilteredConfidence(
334 Handle(), predicate, *reinterpret_cast<CExports::CVC3DCuboid *>(&boundingBox)));
335 });
336
337 return boundingBox;
338 }
339
341
346 {
347 Point3D<double> center;
348 Internal::DoResCall([&]() {
349 return CVB_CALL_CAPI(
350 CVC3DPointCloudCalculateCenterOfGravity(Handle(), *reinterpret_cast<CExports::CVC3DPointD *>(&center)));
351 });
352 return center;
353 }
354
356
361 {
362 Matrix3D matrix;
363 Internal::DoResCall([&]() {
364 return CVB_CALL_CAPI(
365 CVC3DPointCloudCalculateCovarianceMatrix(Handle(), *reinterpret_cast<CExports::CVC3DMatrix *>(&matrix)));
366 });
367 return matrix;
368 }
369
371
377 {
379 }
380
382
388 Plane3D FitPlane(const Cuboid &aoi) const
389 {
390 CExports::CVC3DPlane plane = {0};
391 CExports::cvbres_t res = CVB_CALL_CAPI(CVC3DPointCloudCalculatePlaneFromCuboid(
392 Handle(), *reinterpret_cast<const CExports::CVC3DCuboid *>(&aoi), plane));
393 if (res < 0)
394 std::rethrow_exception(CvbException::FromCvbResult(res, "failed to calculate plane from cuboid."));
395 return Plane3D(plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.DistanceToOrigin);
396 }
397
399
406 template <class T>
407 std::shared_ptr<T> Crop(const Cuboid &clipBox) const
408 {
409 return Internal::DoResCallShareOut<T>([&](void *&handle) {
410 return CVB_CALL_CAPI(
411 CVC3DCreateCroppedPointCloud(Handle(), *reinterpret_cast<const CExports::CVC3DCuboid *>(&clipBox), handle));
412 });
413 }
414
418
439 template <class T>
440 std::shared_ptr<T> FrustumCrop(const Cuboid &clipBox, Angle theta, Angle phi) const
441 {
442 return Internal::DoResCallShareOut<T>([&](void *&handle) {
443 return CVB_CALL_CAPI(CVC3DCreateFrustumCroppedPointCloud(
444 Handle(), *reinterpret_cast<const CExports::CVC3DCuboid *>(&clipBox), theta.Deg(), phi.Deg(), handle));
445 });
446 }
447
450
481 template <class T>
482 std::shared_ptr<T> PlaneCrop(const Plane3D &plane, const ValueRange<double> &range, CropRange cropRange) const
483 {
484 return Internal::DoResCallShareOut<T>([&](void *&handle) {
485 return CVB_CALL_CAPI(
486 CVC3DCreatePlaneCroppedPointCloud(Handle(), *reinterpret_cast<const CExports::CVC3DPlane *>(&plane),
487 *reinterpret_cast<const CExports::CVC3DRange *>(&range),
488 static_cast<CExports::CVC3DCropRange>(cropRange), handle));
489 });
490 }
491
494
526 template <class T>
527 std::shared_ptr<T> PlaneCrop(const Plane3D &plane, double threshold,
528 CropDirection cropBelowAbove = CropDirection::Below) const
529 {
530 // get correct plane
531 auto planeUsed = plane;
532 if (std::fabs(plane.Normal().Z())
533 < 1e-7) // if plane is parallel to z axis above/below is not define -> no cropping is done
535 else if (plane.Normal().Z() < 0) // make sure, that z shows up to get right definition of above and below.
536 {
537 planeUsed.SetNormal(Point3D<double>(-plane.Normal().X(), -plane.Normal().Y(), -plane.Normal().Z()));
538 planeUsed.SetDistanceToOrigin(-plane.DistanceToOrigin());
539 }
540
541 // get correct range
543 if (cropBelowAbove == CropDirection::Above)
545
546 return PlaneCrop<T>(planeUsed, range, CropRange::CropWithinRange);
547 }
548
551
558 {
559 return Internal::DoResCallShareOut<PointCloud>([&](void *&handle) {
560 return CVB_CALL_CAPI(CVC3DCreateDownsampledPointCloud(Handle(),
561 static_cast<CExports::CVC3DDownsampleMode>(mode),
562 static_cast<CExports::cvbint64_t>(value), handle));
563 });
564 }
565
567
575 {
576 return Internal::DoResCallShareOut<PointCloud>(
577 [&](void *&handle) { return CVB_CALL_CAPI(CVC3DCreateDuplicatePointCloud(Handle(), handle)); });
578 }
579
581
585 void Save(const String &fileName) const
586 {
587 Save(fileName, static_cast<PointCloudFlags>(0));
588 }
589
590 void Save(const String &fileName, PointCloudFlags flags) const
591 {
592 Internal::DoResCall([&]() {
593 return CVB_CALL_CAPI(CVC3DWriteFileTyped(Handle(), static_cast<CExports::cvbval_t>(flags), fileName.c_str()));
594 });
595 }
596
599
605 {
606 return Internal::DoResCallShareOut<PointCloud>([&](void *&handle) {
607 return CVB_CALL_CAPI(CVC3DCreateConvertedPointCloud(Handle(), static_cast<CExports::cvbval_t>(flags), handle));
608 });
609 }
610
612
618 {
619 return Internal::DoResCallShareOut<PointCloud>([&](void *&handle) {
620 return CVB_CALL_CAPI(
621 CVC3DCreateScaledPointCloud(Handle(), *reinterpret_cast<CExports::CVC3DFactors *>(&factors), handle));
622 });
623 }
624
626
633 SparsePointCloudPtr Transform(const AffineMatrix3D &transformation) const;
634
636
643 SparsePointCloudPtr Transform(const Matrix3DH &transformation) const;
644
647
652 void Transform(const AffineMatrix3D &affineTransformation, SparsePointCloud &pointCloud);
653
656
661 void Transform(const Cvb::Matrix3DH &transformation, SparsePointCloud &pointCloud);
662
664
674 double background) const
675 {
676 return Internal::DoResCallObjectOut<Image>([&](void *&handle) {
677 return CVB_CALL_CAPI(CVC3DCreateRangeMapFromPointCloud(
678 Handle(), *reinterpret_cast<CExports::CVC3DRange *>(&xRange),
679 *reinterpret_cast<CExports::CVC3DRange *>(&yRange), static_cast<CExports::cvbdim_t>(size.Width()),
680 static_cast<CExports::cvbdim_t>(size.Height()), background, handle));
681 });
682 }
683
685
689 int PlaneCount() const noexcept
690 {
691 CExports::cvbdim_t numPlanes = 0;
692 CVB_CALL_CAPI(CVCPlaneEnumGetCount(Handle(), numPlanes));
693 return static_cast<int>(numPlanes);
694 }
695
697
702 {
704 std::generate_n(std::back_inserter(planes), PlaneCount(), [this, i = 0]() mutable { return Plane(i++); });
705 return planes;
706 }
707
709
716 PlanePtr Plane(int index) const
717 {
718 if (index < 0 || index >= PlaneCount())
719 throw std::length_error("index out of range");
720
721 CExports::CVPLANE handle = nullptr;
722 CVB_CALL_CAPI_CHECKED(CVCPlaneEnumGetAt(Handle(), static_cast<CExports::cvbdim_t>(index), handle));
723 auto plane = Plane::FromHandle(HandleGuard<class Plane>(handle));
724
725 auto iter = planes_.find(plane->Handle());
726 if (iter != planes_.end())
727 {
728 if (auto _plane = iter->second.lock())
729 return _plane;
730 }
731
732 planes_[plane->Handle()] = plane;
733 return plane;
734 }
735
737
753 {
754 std::size_t bufSize{};
755 CExports::cvbres_t res =
756 CVB_CALL_CAPI(CVC3DPointCloudToMemorySize(Handle(), static_cast<CExports::cvbval_t>(flags),
757 static_cast<CExports::CVC3DPointCloudFileFormat>(format), bufSize));
758 if (res < 0)
759 std::rethrow_exception(CvbException::FromCvbResult(res, "failed to get memory size."));
760
761 return bufSize;
762 }
763
765
780 template <class Point>
782 {
783 auto flags = PointTypeToFlags<Point>();
784 return MemorySize(flags, format);
785 }
786
788
811 void ToMemory(PointCloudFlags flags, Cvb::PointCloudFileFormat format, size_t size, void *buffer) const
812 {
813 auto res = CVB_CALL_CAPI(CVC3DPointCloudToMemory(Handle(), static_cast<CExports::cvbval_t>(flags),
814 static_cast<CExports::CVC3DPointCloudFileFormat>(format), buffer,
815 size));
816 if (res < 0)
817 std::rethrow_exception(CvbException::FromCvbResult(res, "failed to save point cloud to memory."));
818 }
819
821
844 template <class Point>
845 void ToMemory(Cvb::PointCloudFileFormat format, size_t size, std::uint8_t *buffer) const
846 {
847 auto flags = PointTypeToFlags<Point>();
848 ToMemory(flags, format, size, buffer);
849 }
850
855 void *Handle() const noexcept
856 {
857 return handle_.Handle();
858 }
859
860 PointCloud(const PointCloud &other) noexcept = delete;
861 PointCloud &operator=(const PointCloud &other) noexcept = delete;
862 PointCloud(PointCloud &&other) noexcept = delete;
863 PointCloud &operator=(PointCloud &&other) noexcept = delete;
864
865 virtual ~PointCloud() = default;
866
867 protected:
868 explicit PointCloud(HandleGuard<PointCloud> &&guard) noexcept
869 : handle_(std::move(guard))
870 {
871 }
872
873 static bool IsDense(void *handle)
874 {
875 CExports::cvbdim_t width = 0;
876 CExports::cvbdim_t height = 0;
877 auto res = CVB_CALL_CAPI(CVC3DPointCloudGetLatticeSize(handle, width, height));
879 return false;
880 else if (res < 0)
881 Utilities::SystemInfo::ThrowLastError(res);
882
883 return true;
884 }
885
886 std::exception_ptr TryPointComponents(ComponentsPointers3D &components) const noexcept
887 {
888 auto res = CVB_CALL_CAPI(CVC3DPointCloudGetPointComponentsPointers(
889 Handle(), reinterpret_cast<void *&>(components.xBasePtr_), components.xInc_,
890 reinterpret_cast<void *&>(components.yBasePtr_), components.yInc_,
891 reinterpret_cast<void *&>(components.zBasePtr_), components.zInc_,
892 reinterpret_cast<void *&>(components.wBasePtr_), components.wInc_, components.numPoints_));
893 if (!CExports::CheckErrorCode(res))
895
896 CExports::cvbdatatype_t dataType = 0;
897 CVB_CALL_CAPI(CVC3DPointCloudGetPointsConfidencePointer(
898 Handle(), reinterpret_cast<void *&>(components.confidenceBasePtr_), components.confidenceInc_, dataType));
899 return {};
900 }
901
902 template <class T>
903 std::exception_ptr TryPointComponents(ComponentsPointers3D &components) const noexcept
904 {
905 auto error = TryPointComponents(components);
906 if (error)
907 return error;
908
910 return std::make_exception_ptr(std::runtime_error("data type does not match for components pointers"));
911
912#ifdef _MSC_VER
913# pragma warning(push, 1)
914# pragma warning(disable : 4127) // conditional expression is constant
915#endif
916
917 if (std::is_same<T, Point3DH<typename T::ValueType>>::value && !components.BasePtrW())
918 return std::make_exception_ptr(std::runtime_error("point cloud has no W components use Point3D"));
919
920 if (std::is_same<T, Point3D<typename T::ValueType>>::value && components.BasePtrW())
921 return std::make_exception_ptr(std::runtime_error("point cloud has W components use Point3DH"));
922
923#ifdef _MSC_VER
924# pragma warning(pop)
925#endif
926
927 return {};
928 }
929
930 private:
931 std::size_t PointsTyped(Cvb::Point3D<double> *&points) const
932 {
933 return Internal::DoResCallValueOut<std::size_t>([&](std::size_t &value) {
934 return CVB_CALL_CAPI(
935 CVC3DPointCloudGetPointDsPointer(Handle(), reinterpret_cast<CExports::CVC3DPointD *&>(points), value));
936 });
937 }
938
939 std::size_t PointsTyped(Point3D<float> *&points) const
940 {
941 return Internal::DoResCallValueOut<std::size_t>([&](std::size_t &value) {
942 return CVB_CALL_CAPI(
943 CVC3DPointCloudGetPointFsPointer(Handle(), reinterpret_cast<CExports::CVC3DPointF *&>(points), value));
944 });
945 }
946
947 std::size_t PointsHTyped(Cvb::Point3DH<double> *&pointsH)
948 {
949 return Internal::DoResCallValueOut<std::size_t>([&](std::size_t &value) {
950 return CVB_CALL_CAPI(
951 CVC3DPointCloudGetPointHDsPointer(Handle(), reinterpret_cast<CExports::CVC3DPointHD *&>(pointsH), value));
952 });
953 }
954
955 std::size_t PointsHTyped(Cvb::Point3DH<float> *&pointsH)
956 {
957 return Internal::DoResCallValueOut<std::size_t>([&](std::size_t &value) {
958 return CVB_CALL_CAPI(
959 CVC3DPointCloudGetPointHFsPointer(Handle(), reinterpret_cast<CExports::CVC3DPointHF *&>(pointsH), value));
960 });
961 }
962
963 mutable std::unordered_map<void *, std::weak_ptr<class Plane>> planes_;
964
965 HandleGuard<PointCloud> handle_;
966 };
967
968 CVB_END_INLINE_NS
969} // namespace Cvb
T back_inserter(T... args)
Affine transformation for 3D containing a transformation matrix and a translation vector.
Definition affine_matrix_3d.hpp:140
Object for convenient and type - safe handling of angles.
Definition angle.hpp:16
double Deg() const noexcept
Get the value in degrees.
Definition angle.hpp:89
Point components of the point cloud.
Definition components_pointers_3d.hpp:18
3D rectangle in the X, Y and Z domain.
Definition cuboid.hpp:19
static DataType FromNativeType() noexcept
Construct a data type descriptor from one of the native data type value equivalents.
Definition data_type.hpp:205
static DataType FromNativeDescriptor(int dataTypeDescriptor) noexcept
Construct a data type descriptor from one of the native library's descriptor values.
Definition data_type.hpp:31
Double precision row-major 4x4 matrix.
Definition matrix_3d_h.hpp:44
Double precision 3x3 matrix class.
Definition matrix_3d.hpp:54
A plane in 3D space in Hessian normal form.
Definition plane_3d.hpp:19
double DistanceToOrigin() const noexcept
Gets the distance to the origin in point units.
Definition plane_3d.hpp:78
Point3D< double > Normal() const noexcept
Gets the normal vector of the plane.
Definition plane_3d.hpp:58
static PlanePtr FromHandle(HandleGuard< Plane > &&guard)
Creates a plane from a classic API handle.
Definition decl_plane.hpp:76
void * Handle() const noexcept override
Classic API image handle.
Definition decl_plane.hpp:98
Multi-purpose 3D vector class with confidence.
Definition point_3d_c.hpp:23
Multi-purpose 3D vector class (homogeneous).
Definition point_3d_h.hpp:22
Multi-purpose 3D vector class.
Definition point_3d.hpp:22
T X() const noexcept
Get the x component of the point.
Definition point_3d.hpp:74
T Y() const noexcept
Get the y component of the point.
Definition point_3d.hpp:94
T Z() const noexcept
Get the z component of the point.
Definition point_3d.hpp:114
A point cloud object.
Definition decl_point_cloud.hpp:74
PlanePtr Plane(int index) const
Index based plane access.
Definition decl_point_cloud.hpp:716
Plane3D FitPlane(const Cuboid &aoi) const
Fits a plane in the points of the point cloud for a specified area of interest.
Definition decl_point_cloud.hpp:388
std::size_t Points(Point3D< T > *&points) const
Gets the 3D points from the given point cloud.
Definition decl_point_cloud.hpp:229
static PointCloudPtr FromHandle(HandleGuard< PointCloud > &&guard)
Creates a point cloud from a classic API handle.
Definition detail_point_cloud.hpp:15
ComponentsPointers3D PointComponents() const
Tries to get the point components from the given point cloud.
Definition decl_point_cloud.hpp:213
std::shared_ptr< T > PlaneCrop(const Plane3D &plane, const ValueRange< double > &range, CropRange cropRange) const
Creates a new point cloud where points within or outside a range parallel to given plane are cropped.
Definition decl_point_cloud.hpp:482
static PointCloudPtr FromMemory(void *buffer, size_t size, Cvb::PointCloudFileFormat format)
Creates a point cloud reading memory from buffer.
Definition decl_point_cloud.hpp:166
PointCloudPtr Convert(PointCloudFlags flags) const
Creates a new point cloud, which is a copy from this point cloud, but with possibly different data ty...
Definition decl_point_cloud.hpp:604
PointCloudPtr Duplicate() const
Creates a new point cloud which is a copy this point cloud.
Definition decl_point_cloud.hpp:574
Cuboid CalculateBoundingBox(const FN &xyzPredicate) const
Calculates the minimum and maximum extent of the point cloud, using a predicate that filters points b...
Definition decl_point_cloud.hpp:291
std::shared_ptr< T > Crop(const Cuboid &clipBox) const
Creates a new point cloud which only consists of the points inside the clip box.
Definition decl_point_cloud.hpp:407
std::shared_ptr< T > FrustumCrop(const Cuboid &clipBox, Angle theta, Angle phi) const
Creates a new point cloud which only consists of the points inside the clipBox, where the orientation...
Definition decl_point_cloud.hpp:440
int PlaneCount() const noexcept
Gets the number of planes enumerated by this object.
Definition decl_point_cloud.hpp:689
void ToMemory(Cvb::PointCloudFileFormat format, size_t size, std::uint8_t *buffer) const
Saves the point cloud to the memory in the given format.
Definition decl_point_cloud.hpp:845
SparsePointCloudPtr Transform(const AffineMatrix3D &transformation) const
Creates a new point cloud with all points being transformed by the given transformation.
Definition detail_point_cloud.hpp:43
Matrix3D CalculateCovarianceMatrix() const
Calculates the covariance matrix of the point cloud.
Definition decl_point_cloud.hpp:360
Cuboid CalculateBoundingBox(bool onlyConfidentPoints=true) const
Calculates the minimum and maximum extent of the point cloud.
Definition decl_point_cloud.hpp:254
class DataType DataType() const
Gets the DataType of the x,y,z(,w) components of the given PointCloud.
Definition decl_point_cloud.hpp:189
PointCloudPtr Downsample(DownSampleMode mode, int value) const
Creates a new point cloud which has several points being removed dependent on the down sample mode an...
Definition decl_point_cloud.hpp:557
std::size_t NumPoints() const
Gets the number of x,y,z(,w) points in the given point cloud.
Definition decl_point_cloud.hpp:201
Plane3D FitPlane() const
Fits a plane in the points of the point cloud without cropping it.
Definition decl_point_cloud.hpp:376
size_t MemorySize(PointCloudFlags flags, Cvb::PointCloudFileFormat format) const
Determines the amount of memory needed for ToMemory.
Definition decl_point_cloud.hpp:752
void ToMemory(PointCloudFlags flags, Cvb::PointCloudFileFormat format, size_t size, void *buffer) const
Saves the point cloud to the memory in the given format.
Definition decl_point_cloud.hpp:811
std::shared_ptr< T > PlaneCrop(const Plane3D &plane, double threshold, CropDirection cropBelowAbove=CropDirection::Below) const
Creates a new point cloud which only consists of the points below or above given plane.
Definition decl_point_cloud.hpp:527
void Save(const String &fileName) const
Saves the given point cloud to the file with the given FileName.
Definition decl_point_cloud.hpp:585
std::unique_ptr< Cvb::Image > RangeMap(ValueRange< double > xRange, ValueRange< double > yRange, Size2D< int > size, double background) const
Creates a new range map image via linear projection in negative z-direction.
Definition decl_point_cloud.hpp:673
static std::shared_ptr< T > FromComposite(CompositePtr object)
Creates a point cloud from a composite.
Definition detail_point_cloud.hpp:27
std::vector< PlanePtr > Planes() const
Gets all available planes enumerated by this object.
Definition decl_point_cloud.hpp:701
PointCloudLayout Layout() const
Get the layout of the available buffers/planes of the given point cloud.
Definition decl_point_cloud.hpp:177
std::size_t PointsH(Point3DH< T > *&pointsH) const
Tries to get the 3D points from the given point cloud.
Definition decl_point_cloud.hpp:241
size_t MemorySize(Cvb::PointCloudFileFormat format) const
Determines the amount of memory needed for ToMemory.
Definition decl_point_cloud.hpp:781
Cuboid CalculateBoundingBox(const FN &confidencePredicate) const
Calculates the minimum and maximum extent of the point cloud, using a predicate that filters points b...
Definition decl_point_cloud.hpp:323
Point3D< double > CalculateCenterOfGravity() const
Calculates the center of gravity of the point cloud.
Definition decl_point_cloud.hpp:345
static PointCloudPtr FromMemory(void *buffer, size_t size, PointCloudFlags flags, Cvb::PointCloudFileFormat format)
Creates a point cloud reading memory from buffer.
Definition detail_point_cloud.hpp:34
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition decl_point_cloud.hpp:855
PointCloudPtr Scale(Factors3D factors) const
Creates a new point cloud with all points being scaled by the given factors.
Definition decl_point_cloud.hpp:617
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
T Height() const noexcept
Gets the vertical component of the size.
Definition size_2d.hpp:77
T Width() const noexcept
Gets the horizontal component of the size.
Definition size_2d.hpp:57
An unorganized sparse Cartesian 3D point cloud object.
Definition decl_sparse_point_cloud.hpp:34
Container for range definitions.
Definition value_range.hpp:17
T epsilon(T... args)
T fabs(T... args)
T generate_n(T... args)
cvbbool_t ReleaseObject(OBJ &Object)
T lowest(T... args)
T max(T... args)
T move(T... args)
const int CVB_INVALIDDIMENSION
Invalid number of dimensions.
Definition exception.hpp:73
std::exception_ptr GetLastError() noexcept
Returns a pointer that points at the exception.
Definition system_info.hpp:181
Root namespace for the Image Manager interface.
Definition version.hpp:11
PointCloudFileFormat
Supported point cloud point formats.
Definition core_3d.hpp:141
PointCloudFlags
Flags for creating point clouds.
Definition core_3d.hpp:90
@ Float
Definition core_3d.hpp:94
@ XYZW
Definition core_3d.hpp:109
@ XYZConfidence
Definition core_3d.hpp:114
@ Double
Definition core_3d.hpp:99
@ XYZ
Definition core_3d.hpp:104
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49
std::shared_ptr< PointCloud > PointCloudPtr
Convenience shared pointer for PointCloud.
Definition core_3d.hpp:40
CropRange
Indicates cropping range.
Definition core_3d.hpp:288
@ CropWithinRange
Crops points within given range.
Definition core_3d.hpp:291
PointCloudLayout
Supported point cloud point layouts.
Definition core_3d.hpp:195
std::shared_ptr< SparsePointCloud > SparsePointCloudPtr
Convenience shared pointer for SparsePointCloud.
Definition core_3d.hpp:48
CropDirection
Indicates cropping direction.
Definition core_3d.hpp:301
@ Above
Crop above given plane.
Definition core_3d.hpp:309
@ Below
Crop below given plane.
Definition core_3d.hpp:305
DownSampleMode
Specifies how to remove points from a point cloud.
Definition core_3d.hpp:234
@ PixConfidence
Confidence(probability density / percentage) or consistency(Boolean) value.
Definition global.hpp:442
std::shared_ptr< Composite > CompositePtr
Convenience shared pointer for Composite.
Definition global.hpp:102
std::shared_ptr< Plane > PlanePtr
Convenience shared pointer for Plane.
Definition global.hpp:78
T dynamic_pointer_cast(T... args)
T rethrow_exception(T... args)
Factor components to be applied in the 3D domain.
Definition core_3d.hpp:16