libvisiontransfer  6.2.1
reconstruct3d.h
1 /*******************************************************************************
2  * Copyright (c) 2018 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/imagepair.h"
22 
29 class VT_EXPORT Reconstruct3D {
30 public:
34  Reconstruct3D();
35 
36  ~Reconstruct3D();
37 
68  float* createPointMap(const unsigned short* dispMap, int width, int height,
69  int rowStride, const float* q, unsigned short minDisparity = 1);
70 
83  float* createPointMap(const ImagePair& imagePair, unsigned short minDisparity = 1);
84 
105  void projectSinglePoint(int imageX, int imageY, unsigned short disparity, const float* q,
106  float& pointX, float& pointY, float& pointZ);
107 
133  void writePlyFile(const char* file, const unsigned short* dispMap,
134  const unsigned char* image, int width, int height, ImagePair::ImageFormat format,
135  int dispRowStride, int imageRowStride, const float* q,
136  double maxZ = std::numeric_limits<double>::max(),
137  bool binary = false);
138 
153  void writePlyFile(const char* file, const ImagePair& imagePair,
154  double maxZ = std::numeric_limits<double>::max(), bool binary = false);
155 
156 #ifdef PCL_MAJOR_VERSION
157 
172  inline pcl::PointCloud<pcl::PointXYZ>::Ptr createXYZCloud(const ImagePair& imagePair,
173  const char* frameId, unsigned short minDisparity = 0);
174 
180  inline pcl::PointCloud<pcl::PointXYZI>::Ptr createXYZICloud(const ImagePair& imagePair,
181  const char* frameId, unsigned short minDisparity = 0);
182 
188  inline pcl::PointCloud<pcl::PointXYZRGB>::Ptr createXYZRGBCloud(const ImagePair& imagePair,
189  const char* frameId, unsigned short minDisparity = 0);
190 #endif
191 
192 private:
193  // We follow the pimpl idiom
194  class Pimpl;
195  Pimpl* pimpl;
196 
197  // This class cannot be copied
198  Reconstruct3D(const Reconstruct3D& other);
199  Reconstruct3D& operator=(const Reconstruct3D&);
200 
201 #ifdef PCL_MAJOR_VERSION
202  // Initializes a PCL point cloud
203  template <typename T>
204  typename pcl::PointCloud<T>::Ptr initPointCloud(const ImagePair& imagePair, const char* frameId);
205 #endif
206 };
207 
208 #include "visiontransfer/reconstruct3d-pcl.h"
209 
210 #endif
Transforms a disparity map into a set of 3D points.
Definition: reconstruct3d.h:29
A set of two images, which are usually the left camera image and the disparity map.
Definition: imagepair.h:31
ImageFormat
Image formats that can be transferred.
Definition: imagepair.h:36
Nerian Vision Technologies