Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #pragma once
00029
00030 #include "rtabmap/core/RtabmapExp.h"
00031
00032 #include <opencv2/highgui/highgui.hpp>
00033 #include "rtabmap/core/Camera.h"
00034 #include "rtabmap/utilite/UTimer.h"
00035 #include <set>
00036 #include <stack>
00037 #include <list>
00038 #include <vector>
00039
00040 class UDirectory;
00041
00042 namespace rtabmap
00043 {
00044
00046
00048 class RTABMAP_EXP CameraImages :
00049 public Camera
00050 {
00051 public:
00052 CameraImages();
00053 CameraImages(
00054 const std::string & path,
00055 float imageRate = 0,
00056 const Transform & localTransform = Transform::getIdentity());
00057 virtual ~CameraImages();
00058
00059 virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
00060 virtual bool isCalibrated() const;
00061 virtual std::string getSerial() const;
00062 std::string getPath() const {return _path;}
00063 unsigned int imagesCount() const;
00064 std::vector<std::string> filenames() const;
00065 bool isImagesRectified() const {return _rectifyImages;}
00066 int getBayerMode() const {return _bayerMode;}
00067 const CameraModel & cameraModel() const {return _model;}
00068
00069 void setPath(const std::string & dir) {_path=dir;}
00070 void setStartIndex(int index) {_startAt = index;}
00071 void setDirRefreshed(bool enabled) {_refreshDir = enabled;}
00072 void setImagesRectified(bool enabled) {_rectifyImages = enabled;}
00073 void setBayerMode(int mode) {_bayerMode = mode;}
00074
00075 void setTimestamps(bool fileNamesAreStamps, const std::string & filePath = "", bool syncImageRateWithStamps=true)
00076 {
00077 _filenamesAreTimestamps = fileNamesAreStamps;
00078 timestampsPath_=filePath;
00079 syncImageRateWithStamps_ = syncImageRateWithStamps;
00080 }
00081
00082 void setScanPath(
00083 const std::string & dir,
00084 int maxScanPts = 0,
00085 int downsampleStep = 1,
00086 float voxelSize = 0.0f,
00087 int normalsK = 0,
00088 const Transform & localTransform=Transform::getIdentity())
00089 {
00090 _scanPath = dir;
00091 _scanLocalTransform = localTransform;
00092 _scanMaxPts = maxScanPts;
00093 _scanDownsampleStep = downsampleStep;
00094 _scanNormalsK = normalsK;
00095 _scanVoxelSize = voxelSize;
00096 if(_scanDownsampleStep>1)
00097 {
00098 _scanMaxPts /= _scanDownsampleStep;
00099 }
00100 }
00101
00102 void setDepthFromScan(bool enabled, int fillHoles = 1, bool fillHolesFromBorder = false)
00103 {
00104 _depthFromScan = enabled;
00105 _depthFromScanFillHoles = fillHoles;
00106 _depthFromScanFillHolesFromBorder = fillHolesFromBorder;
00107 }
00108
00109 void setGroundTruthPath(const std::string & filePath, int format = 0)
00110 {
00111 groundTruthPath_ = filePath;
00112 _groundTruthFormat = format;
00113 }
00114
00115 void setDepth(bool isDepth, float depthScaleFactor = 1.0f)
00116 {
00117 _isDepth = isDepth;
00118 _depthScaleFactor=depthScaleFactor;
00119 }
00120
00121 protected:
00122 virtual SensorData captureImage(CameraInfo * info = 0);
00123
00124 private:
00125 std::string _path;
00126 int _startAt;
00127
00128
00129 bool _refreshDir;
00130 bool _rectifyImages;
00131 int _bayerMode;
00132 bool _isDepth;
00133 float _depthScaleFactor;
00134 int _count;
00135 UDirectory * _dir;
00136 std::string _lastFileName;
00137
00138 int _countScan;
00139 UDirectory * _scanDir;
00140 std::string _lastScanFileName;
00141 std::string _scanPath;
00142 Transform _scanLocalTransform;
00143 int _scanMaxPts;
00144 int _scanDownsampleStep;
00145 float _scanVoxelSize;
00146 int _scanNormalsK;
00147
00148 bool _depthFromScan;
00149 int _depthFromScanFillHoles;
00150 bool _depthFromScanFillHolesFromBorder;
00151
00152 bool _filenamesAreTimestamps;
00153 std::string timestampsPath_;
00154 bool syncImageRateWithStamps_;
00155
00156 std::string groundTruthPath_;
00157 int _groundTruthFormat;
00158
00159 std::list<double> stamps_;
00160 std::list<Transform> groundTruth_;
00161 CameraModel _model;
00162
00163 UTimer _captureTimer;
00164 double _captureDelay;
00165 };
00166
00167
00168
00169
00171
00173 class RTABMAP_EXP CameraVideo :
00174 public Camera
00175 {
00176 public:
00177 enum Source{kVideoFile, kUsbDevice};
00178
00179 public:
00180 CameraVideo(int usbDevice = 0,
00181 bool rectifyImages = false,
00182 float imageRate = 0,
00183 const Transform & localTransform = Transform::getIdentity());
00184 CameraVideo(const std::string & filePath,
00185 bool rectifyImages = false,
00186 float imageRate = 0,
00187 const Transform & localTransform = Transform::getIdentity());
00188 virtual ~CameraVideo();
00189
00190 virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
00191 virtual bool isCalibrated() const;
00192 virtual std::string getSerial() const;
00193 int getUsbDevice() const {return _usbDevice;}
00194 const std::string & getFilePath() const {return _filePath;}
00195
00196 protected:
00197 virtual SensorData captureImage(CameraInfo * info = 0);
00198
00199 private:
00200
00201 std::string _filePath;
00202 bool _rectifyImages;
00203
00204 cv::VideoCapture _capture;
00205 Source _src;
00206
00207
00208 int _usbDevice;
00209 std::string _guid;
00210
00211 CameraModel _model;
00212 };
00213
00214
00215 }