libvisiontransfer  8.3.0
reconstruct3d.h
1 /*******************************************************************************
2  * Copyright (c) 2020 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 namespace visiontransfer {
24 
31 class VT_EXPORT Reconstruct3D {
32 public:
36  Reconstruct3D();
37 
38  ~Reconstruct3D();
39 
71  float* createPointMap(const unsigned short* dispMap, int width, int height,
72  int rowStride, const float* q, unsigned short minDisparity = 1,
73  int subpixelFactor = 16);
74 
87  float* createPointMap(const ImageSet& imageSet, unsigned short minDisparity = 1);
88 
111  void projectSinglePoint(int imageX, int imageY, unsigned short disparity, const float* q,
112  float& pointX, float& pointY, float& pointZ, int subpixelFactor = 16);
113 
140  void writePlyFile(const char* file, const unsigned short* dispMap,
141  const unsigned char* image, int width, int height, ImageSet::ImageFormat format,
142  int dispRowStride, int imageRowStride, const float* q,
143  double maxZ = std::numeric_limits<double>::max(),
144  bool binary = false, int subpixelFactor = 16);
145 
161  void writePlyFile(const char* file, const ImageSet& imageSet,
162  double maxZ = std::numeric_limits<double>::max(), bool binary = false);
163 
164 #ifdef PCL_MAJOR_VERSION
165 
180  inline pcl::PointCloud<pcl::PointXYZ>::Ptr createXYZCloud(const ImageSet& imageSet,
181  const char* frameId, unsigned short minDisparity = 0);
182 
188  inline pcl::PointCloud<pcl::PointXYZI>::Ptr createXYZICloud(const ImageSet& imageSet,
189  const char* frameId, unsigned short minDisparity = 0);
190 
196  inline pcl::PointCloud<pcl::PointXYZRGB>::Ptr createXYZRGBCloud(const ImageSet& imageSet,
197  const char* frameId, unsigned short minDisparity = 0);
198 #endif
199 
200 private:
201  // We follow the pimpl idiom
202  class Pimpl;
203  Pimpl* pimpl;
204 
205  // This class cannot be copied
206  Reconstruct3D(const Reconstruct3D& other);
207  Reconstruct3D& operator=(const Reconstruct3D&);
208 
209 #ifdef PCL_MAJOR_VERSION
210  // Initializes a PCL point cloud
211  template <typename T>
212  typename pcl::PointCloud<T>::Ptr initPointCloud(const ImageSet& imageSet, const char* frameId);
213 #endif
214 };
215 
216 } // namespace
217 
218 #include "visiontransfer/reconstruct3d-pcl.h"
219 
220 #endif
Transforms a disparity map into a set of 3D points.
Definition: reconstruct3d.h:31
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