CameraRGBDImages.cpp
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 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
19 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
28 
29 namespace rtabmap
30 {
31 
33 {
34  return true;
35 }
36 
38  const std::string & pathRGBImages,
39  const std::string & pathDepthImages,
40  float depthScaleFactor,
41  float imageRate,
42  const Transform & localTransform) :
43  CameraImages(pathRGBImages, imageRate, localTransform)
44 {
45  UASSERT(depthScaleFactor >= 1.0);
46  cameraDepth_.setPath(pathDepthImages);
47  cameraDepth_.setDepth(true, depthScaleFactor);
48 }
49 
51 {
52 }
53 
54 bool CameraRGBDImages::init(const std::string & calibrationFolder, const std::string & cameraName)
55 {
56  bool success = false;
57  if(CameraImages::init(calibrationFolder, cameraName) && cameraDepth_.init())
58  {
59  if(this->imagesCount() == cameraDepth_.imagesCount())
60  {
61  success = true;
62  }
63  else
64  {
65  UERROR("Cameras don't have the same number of images (%d vs %d)",
67  }
68  }
69 
70  return success;
71 }
72 
74 {
76 
77  SensorData rgb, depth;
78  rgb = CameraImages::captureImage(info);
79  if(!rgb.imageRaw().empty())
80  {
81  depth = cameraDepth_.takeImage();
82  if(!depth.depthRaw().empty())
83  {
84  data = SensorData(rgb.imageRaw(), depth.depthRaw(), rgb.cameraModels(), rgb.id(), rgb.stamp());
85  data.setGroundTruth(rgb.groundTruth());
86  }
87  }
88  return data;
89 }
90 
91 
92 } // namespace rtabmap
void setPath(const std::string &dir)
Definition: CameraImages.h:63
virtual SensorData captureImage(CameraInfo *info=0)
data
#define UASSERT(condition)
SensorData takeImage(CameraInfo *info=0)
Definition: Camera.cpp:72
int id() const
Definition: SensorData.h:174
const std::vector< CameraModel > & cameraModels() const
Definition: SensorData.h:236
cv::Mat depthRaw() const
Definition: SensorData.h:210
const cv::Mat & imageRaw() const
Definition: SensorData.h:183
void setDepth(bool isDepth, float depthScaleFactor=1.0f)
Definition: CameraImages.h:116
unsigned int imagesCount() const
const Transform & groundTruth() const
Definition: SensorData.h:280
virtual SensorData captureImage(CameraInfo *info=0)
#define UERROR(...)
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
double stamp() const
Definition: SensorData.h:176
CameraRGBDImages(const std::string &pathRGBImages, const std::string &pathDepthImages, float depthScaleFactor=1.0f, float imageRate=0.0f, const Transform &localTransform=Transform::getIdentity())
void setGroundTruth(const Transform &pose)
Definition: SensorData.h:279
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:28