libvisiontransfer  10.0.0
reconstruct3d.h
1 /*******************************************************************************
2  * Copyright (c) 2022 Nerian Vision GmbH
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *******************************************************************************/
14 
15 #ifndef VISIONTRANSFER_RECONSTRUCT3D_H
16 #define VISIONTRANSFER_RECONSTRUCT3D_H
17 
18 #include <limits>
19 #include <stdexcept>
20 #include "visiontransfer/common.h"
21 #include "visiontransfer/imageset.h"
22 
23 #ifdef OPEN3D_VERSION
24 # include <memory>
25 #endif
26 
27 namespace visiontransfer {
28 
35 class VT_EXPORT Reconstruct3D {
36 public:
40  Reconstruct3D();
41 
42  ~Reconstruct3D();
43 
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 
69  DEPRECATED("Use createPointMap(const ImageSet&, ...) instead.")
70  float* createPointMap(const unsigned short* dispMap, int width, int height,
71  int rowStride, const float* q, unsigned short minDisparity = 1,
72  int subpixelFactor = 16, unsigned short maxDisparity = 0xFFF);
73 #endif
74 
94  float* createPointMap(const ImageSet& imageSet, unsigned short minDisparity = 1);
95 
119  float* createZMap(const ImageSet& imageSet, unsigned short minDisparity = 1,
120  unsigned short maxDisparity = 0xFFF);
121 
144  void projectSinglePoint(int imageX, int imageY, unsigned short disparity, const float* q,
145  float& pointX, float& pointY, float& pointZ, int subpixelFactor = 16);
146 
147 #ifndef DOXYGEN_SHOULD_SKIP_THIS
148 
177  DEPRECATED("Use writePlyFile(const char*, const ImageSet&, ...) instead.")
178  void writePlyFile(const char* file, const unsigned short* dispMap,
179  const unsigned char* image, int width, int height, ImageSet::ImageFormat format,
180  int dispRowStride, int imageRowStride, const float* q,
181  double maxZ = std::numeric_limits<double>::max(),
182  bool binary = false, int subpixelFactor = 16, unsigned short maxDisparity = 0xFFF);
183 #endif
184 
195  void writePlyFile(const char* file, const ImageSet& imageSet,
196  double maxZ = std::numeric_limits<double>::max(), bool binary = false);
197 
198 #ifdef PCL_MAJOR_VERSION
199 
214  inline pcl::PointCloud<pcl::PointXYZ>::Ptr createXYZCloud(const ImageSet& imageSet,
215  const char* frameId, unsigned short minDisparity = 0);
216 
222  inline pcl::PointCloud<pcl::PointXYZI>::Ptr createXYZICloud(const ImageSet& imageSet,
223  const char* frameId, unsigned short minDisparity = 0);
224 
230  inline pcl::PointCloud<pcl::PointXYZRGB>::Ptr createXYZRGBCloud(const ImageSet& imageSet,
231  const char* frameId, unsigned short minDisparity = 0);
232 #endif
233 
234 #ifdef OPEN3D_VERSION
235 
251  inline std::shared_ptr<open3d::geometry::PointCloud> createOpen3DCloud(const ImageSet& imageSet,
252  bool withColor, unsigned short minDisparity = 0);
267  inline std::shared_ptr<open3d::geometry::RGBDImage> createOpen3DImageRGBD(const ImageSet& imageSet,
268  unsigned short minDisparity = 0);
269 #endif
270 
271 private:
272  // We follow the pimpl idiom
273  class Pimpl;
274  Pimpl* pimpl;
275 
276  // This class cannot be copied
277  Reconstruct3D(const Reconstruct3D& other);
278  Reconstruct3D& operator=(const Reconstruct3D&);
279 
280 #ifdef PCL_MAJOR_VERSION
281  // Initializes a PCL point cloud
282  template <typename T>
283  typename pcl::PointCloud<T>::Ptr initPointCloud(const ImageSet& imageSet, const char* frameId);
284 #endif
285 };
286 
287 } // namespace
288 
289 #include "visiontransfer/reconstruct3d-pcl.h"
290 #include "visiontransfer/reconstruct3d-open3d.h"
291 
292 #endif
Transforms a disparity map into a set of 3D points.
Definition: reconstruct3d.h:35
ImageFormat
Image formats that can be transferred.
Definition: imageset.h:44
A set of one to three images, but usually two (the left camera image and the disparity map)...
Definition: imageset.h:38
Nerian Vision Technologies