CameraImages.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #pragma once
29 
30 #include "rtabmap/core/Camera.h"
31 #include "rtabmap/utilite/UTimer.h"
32 #include <list>
33 
34 class UDirectory;
35 
36 namespace rtabmap
37 {
38 
39 class RTABMAP_CORE_EXPORT CameraImages :
40  public Camera
41 {
42 public:
43  CameraImages();
45  const std::string & path,
46  float imageRate = 0,
47  const Transform & localTransform = Transform::getIdentity());
48  virtual ~CameraImages();
49 
50  virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
51  virtual bool isCalibrated() const;
52  virtual std::string getSerial() const;
53  virtual bool odomProvided() const { return odometry_.size() > 0; }
54  std::string getPath() const {return _path;}
55  unsigned int imagesCount() const;
56  std::vector<std::string> filenames() const;
57  bool isImagesRectified() const {return _rectifyImages;}
58  int getBayerMode() const {return _bayerMode;}
59  const CameraModel & cameraModel() const {return _model;}
60 
61  void setPath(const std::string & dir) {_path=dir;}
62  virtual void setStartIndex(int index) {_startAt = index;} // negative means last
63  virtual void setMaxFrames(int value) {_maxFrames = value;}
64  void setDirRefreshed(bool enabled) {_refreshDir = enabled;}
65  void setImagesRectified(bool enabled) {_rectifyImages = enabled;}
66  void setBayerMode(int mode) {_bayerMode = mode;} // -1=disabled (default) 0=BayerBG, 1=BayerGB, 2=BayerRG, 3=BayerGR
67 
68  void setTimestamps(bool fileNamesAreStamps, const std::string & filePath = "", bool syncImageRateWithStamps=true)
69  {
70  _filenamesAreTimestamps = fileNamesAreStamps;
71  _timestampsPath=filePath;
72  _syncImageRateWithStamps = syncImageRateWithStamps;
73  }
74 
75  void setConfigForEachFrame(bool value)
76  {
77  _hasConfigForEachFrame = value;
78  }
79 
81  const std::string & dir,
82  int maxScanPts = 0,
83  const Transform & localTransform=Transform::getIdentity())
84  {
85  _scanPath = dir;
86  _scanLocalTransform = localTransform;
87  _scanMaxPts = maxScanPts;
88  }
89 
90  void setDepthFromScan(bool enabled, int fillHoles = 1, bool fillHolesFromBorder = false)
91  {
92  _depthFromScan = enabled;
93  _depthFromScanFillHoles = fillHoles;
94  _depthFromScanFillHolesFromBorder = fillHolesFromBorder;
95  }
96 
97  // Format: 0=Raw, 1=RGBD-SLAM, 2=KITTI, 3=TORO, 4=g2o, 5=NewCollege(t,x,y), 6=Malaga Urban GPS, 7=St Lucia INS, 8=Karlsruhe
98  void setOdometryPath(const std::string & filePath, int format = 0)
99  {
100  _odometryPath = filePath;
101  _odometryFormat = format;
102  }
103 
104  // Format: 0=Raw, 1=RGBD-SLAM, 2=KITTI, 3=TORO, 4=g2o, 5=NewCollege(t,x,y), 6=Malaga Urban GPS, 7=St Lucia INS, 8=Karlsruhe
105  void setGroundTruthPath(const std::string & filePath, int format = 0)
106  {
107  _groundTruthPath = filePath;
108  _groundTruthFormat = format;
109  }
110 
111  void setMaxPoseTimeDiff(double diff) {_maxPoseTimeDiff = diff;}
112  double getMaxPoseTimeDiff() const {return _maxPoseTimeDiff;}
113 
114  void setDepth(bool isDepth, float depthScaleFactor = 1.0f)
115  {
116  _isDepth = isDepth;
117  _depthScaleFactor=depthScaleFactor;
118  }
119 
120 protected:
121  virtual SensorData captureImage(SensorCaptureInfo * info = 0);
122 
123 private:
124  bool readPoses(
125  std::list<Transform> & outputPoses,
126  std::list<double> & stamps,
127  const std::string & filePath,
128  int format,
129  double maxTimeDiff) const;
130 
131 private:
132  std::string _path;
133  int _startAt;
135  // If the list of files in the directory is refreshed
136  // on each call of takeImage()
140  bool _isDepth;
142  int _count;
145  std::string _lastFileName;
146 
149  std::string _lastScanFileName;
150  std::string _scanPath;
153 
155  int _depthFromScanFillHoles; // <0:horizontal 0:disabled >0:vertical
157 
160  std::string _timestampsPath;
162 
163  std::string _odometryPath;
165  std::string _groundTruthPath;
168 
169  std::list<double> _stamps;
170  std::list<Transform> odometry_;
171  std::list<cv::Mat> covariances_;
172  std::list<Transform> groundTruth_;
174  std::list<CameraModel> _models;
175 
178 };
179 
180 
181 } // namespace rtabmap
rtabmap::SensorData
Definition: SensorData.h:51
rtabmap::CameraImages
Definition: CameraImages.h:39
format
std::string format(const std::string &str, const std::vector< std::string > &find, const std::vector< std::string > &replace)
rtabmap::CameraImages::_hasConfigForEachFrame
bool _hasConfigForEachFrame
Definition: CameraImages.h:159
rtabmap::CameraImages::setPath
void setPath(const std::string &dir)
Definition: CameraImages.h:61
rtabmap::CameraImages::setImagesRectified
void setImagesRectified(bool enabled)
Definition: CameraImages.h:65
rtabmap::CameraImages::_scanLocalTransform
Transform _scanLocalTransform
Definition: CameraImages.h:151
rtabmap::CameraImages::_models
std::list< CameraModel > _models
Definition: CameraImages.h:174
rtabmap::CameraImages::_groundTruthPath
std::string _groundTruthPath
Definition: CameraImages.h:165
rtabmap::CameraImages::_lastFileName
std::string _lastFileName
Definition: CameraImages.h:145
rtabmap::CameraImages::_model
CameraModel _model
Definition: CameraImages.h:173
rtabmap::CameraImages::isImagesRectified
bool isImagesRectified() const
Definition: CameraImages.h:57
rtabmap::CameraImages::_framesPublished
int _framesPublished
Definition: CameraImages.h:143
rtabmap::CameraImages::setScanPath
void setScanPath(const std::string &dir, int maxScanPts=0, const Transform &localTransform=Transform::getIdentity())
Definition: CameraImages.h:80
rtabmap::CameraImages::setOdometryPath
void setOdometryPath(const std::string &filePath, int format=0)
Definition: CameraImages.h:98
rtabmap::Transform::getIdentity
static Transform getIdentity()
Definition: Transform.cpp:411
rtabmap::CameraModel
Definition: CameraModel.h:38
rtabmap::CameraImages::_startAt
int _startAt
Definition: CameraImages.h:133
rtabmap::CameraImages::setConfigForEachFrame
void setConfigForEachFrame(bool value)
Definition: CameraImages.h:75
rtabmap::CameraImages::cameraModel
const CameraModel & cameraModel() const
Definition: CameraImages.h:59
rtabmap::CameraImages::getMaxPoseTimeDiff
double getMaxPoseTimeDiff() const
Definition: CameraImages.h:112
rtabmap::CameraImages::_maxFrames
int _maxFrames
Definition: CameraImages.h:134
rtabmap::CameraImages::setDirRefreshed
void setDirRefreshed(bool enabled)
Definition: CameraImages.h:64
rtabmap::CameraImages::getBayerMode
int getBayerMode() const
Definition: CameraImages.h:58
UTimer.h
rtabmap::CameraImages::_odometryFormat
int _odometryFormat
Definition: CameraImages.h:164
rtabmap::CameraImages::_scanDir
UDirectory * _scanDir
Definition: CameraImages.h:148
rtabmap::SensorCaptureInfo
Definition: SensorCaptureInfo.h:36
rtabmap::CameraImages::_maxPoseTimeDiff
double _maxPoseTimeDiff
Definition: CameraImages.h:167
rtabmap::CameraImages::_stamps
std::list< double > _stamps
Definition: CameraImages.h:169
mode
const DiscreteKey mode
rtabmap::CameraImages::setGroundTruthPath
void setGroundTruthPath(const std::string &filePath, int format=0)
Definition: CameraImages.h:105
rtabmap::CameraImages::_bayerMode
int _bayerMode
Definition: CameraImages.h:139
rtabmap::CameraImages::_captureTimer
UTimer _captureTimer
Definition: CameraImages.h:176
rtabmap::CameraImages::_scanMaxPts
int _scanMaxPts
Definition: CameraImages.h:152
rtabmap::CameraImages::_odometryPath
std::string _odometryPath
Definition: CameraImages.h:163
rtabmap::CameraImages::setDepthFromScan
void setDepthFromScan(bool enabled, int fillHoles=1, bool fillHolesFromBorder=false)
Definition: CameraImages.h:90
rtabmap::CameraImages::_depthFromScanFillHoles
int _depthFromScanFillHoles
Definition: CameraImages.h:155
rtabmap::CameraImages::_dir
UDirectory * _dir
Definition: CameraImages.h:144
rtabmap::CameraImages::setBayerMode
void setBayerMode(int mode)
Definition: CameraImages.h:66
rtabmap::Camera
Definition: Camera.h:43
rtabmap::CameraImages::setStartIndex
virtual void setStartIndex(int index)
Definition: CameraImages.h:62
rtabmap::CameraImages::setMaxPoseTimeDiff
void setMaxPoseTimeDiff(double diff)
Definition: CameraImages.h:111
rtabmap::CameraImages::setDepth
void setDepth(bool isDepth, float depthScaleFactor=1.0f)
Definition: CameraImages.h:114
path
path
rtabmap::CameraImages::_lastScanFileName
std::string _lastScanFileName
Definition: CameraImages.h:149
rtabmap::CameraImages::setTimestamps
void setTimestamps(bool fileNamesAreStamps, const std::string &filePath="", bool syncImageRateWithStamps=true)
Definition: CameraImages.h:68
rtabmap_netvlad.init
def init(descriptorDim)
Definition: rtabmap_netvlad.py:30
rtabmap::Transform
Definition: Transform.h:41
rtabmap::CameraImages::_timestampsPath
std::string _timestampsPath
Definition: CameraImages.h:160
rtabmap::CameraImages::odometry_
std::list< Transform > odometry_
Definition: CameraImages.h:170
rtabmap::CameraImages::_countScan
int _countScan
Definition: CameraImages.h:147
rtabmap::CameraImages::_filenamesAreTimestamps
bool _filenamesAreTimestamps
Definition: CameraImages.h:158
rtabmap::CameraImages::_isDepth
bool _isDepth
Definition: CameraImages.h:140
rtabmap::CameraImages::_depthFromScanFillHolesFromBorder
bool _depthFromScanFillHolesFromBorder
Definition: CameraImages.h:156
rtabmap::CameraImages::setMaxFrames
virtual void setMaxFrames(int value)
Definition: CameraImages.h:63
rtabmap::CameraImages::_rectifyImages
bool _rectifyImages
Definition: CameraImages.h:138
rtabmap::CameraImages::getPath
std::string getPath() const
Definition: CameraImages.h:54
rtabmap::CameraImages::_count
int _count
Definition: CameraImages.h:142
rtabmap::CameraImages::_syncImageRateWithStamps
bool _syncImageRateWithStamps
Definition: CameraImages.h:161
diff
diff
rtabmap::CameraImages::_depthFromScan
bool _depthFromScan
Definition: CameraImages.h:154
Camera.h
UTimer
Definition: UTimer.h:46
rtabmap::CameraImages::_refreshDir
bool _refreshDir
Definition: CameraImages.h:137
rtabmap::CameraImages::_scanPath
std::string _scanPath
Definition: CameraImages.h:150
rtabmap::CameraImages::_depthScaleFactor
float _depthScaleFactor
Definition: CameraImages.h:141
rtabmap::CameraImages::covariances_
std::list< cv::Mat > covariances_
Definition: CameraImages.h:171
rtabmap
Definition: CameraARCore.cpp:35
UDirectory
Definition: UDirectory.h:34
rtabmap::CameraImages::_path
std::string _path
Definition: CameraImages.h:132
value
value
rtabmap::CameraImages::_groundTruthFormat
int _groundTruthFormat
Definition: CameraImages.h:166
rtabmap::CameraImages::groundTruth_
std::list< Transform > groundTruth_
Definition: CameraImages.h:172
rtabmap::CameraImages::_captureDelay
double _captureDelay
Definition: CameraImages.h:177
rtabmap::CameraImages::odomProvided
virtual bool odomProvided() const
Definition: CameraImages.h:53


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:07