RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
CameraStereoImages.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#pragma once
29
30#include <rtabmap/core/camera/CameraImages.h>
31
32#include "rtabmap/core/StereoCameraModel.h"
33#include "rtabmap/core/Version.h"
34
35namespace rtabmap
36{
37
38class CameraImages;
39class RTABMAP_CORE_EXPORT CameraStereoImages :
40 public CameraImages
41{
42public:
43 static bool available();
44
45public:
47 const std::string & pathLeftImages,
48 const std::string & pathRightImages,
49 bool rectifyImages = false,
50 float imageRate=0.0f,
51 const Transform & localTransform = Transform::getIdentity());
53 const std::string & pathLeftRightImages,
54 bool rectifyImages = false,
55 float imageRate=0.0f,
56 const Transform & localTransform = Transform::getIdentity());
57 virtual ~CameraStereoImages();
58
59 void setRightGrayScale(bool enabled = true) {rightGrayScale_ = enabled;}
60
61 // Enable multi-camera stereo mode. Each left/right image in the folders is
62 // expected to be the horizontal concatenation of N sub-camera images of a
63 // stereo rig, all sharing the same base name (timestamp or node id), e.g.
64 // "1779318290.502227.jpg". Two calibration files per sub-camera must exist in
65 // the calibrationFolder passed to init(), named "<prefix>_<index>_left.yaml"
66 // and "<prefix>_<index>_right.yaml" with index starting at 0. The number of
67 // cameras is auto-detected. Sub-images are split using a uniform width
68 // (stackedWidth / N).
69 // If setConfigForEachFrame() is enabled, one calibration set is loaded per frame
70 // using each image's base name as prefix. Otherwise a single calibration set is
71 // loaded and reused for all frames, using the cameraName passed to init() as
72 // prefix (it may differ from any image name), falling back to the first image's
73 // base name when cameraName is empty.
74 // Note that it is not recommended to use setConfigForEachFrame() if images have
75 // to be rectified, a rectification matrix would need to be re-initilaized for each
76 // frame.
77 void setMultiCameraCalibration(bool enabled) {CameraImages::setMultiCameraCalibration(enabled);}
78
79 virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
80 virtual bool isCalibrated() const;
81 virtual std::string getSerial() const;
82
83 virtual void setStartIndex(int index) {CameraImages::setStartIndex(index);camera2_->setStartIndex(index);} // negative means last
84 virtual void setMaxFrames(int value) {CameraImages::setMaxFrames(value);camera2_->setMaxFrames(value);}
85
86protected:
87 virtual SensorData captureImage(SensorCaptureInfo * info = 0);
88
89private:
90 // Load the sub-camera stereo models of a frame from calibration files named
91 // "<baseName>_<index>_{left,right}.yaml" (index 0.._multiCameraCount-1) in
92 // _calibrationFolder. Returns an empty vector (and logs an error) on failure.
93 std::vector<StereoCameraModel> loadStereoCameraModels(const std::string & baseName, bool rectify) const;
94
95private:
96 CameraImages * camera2_;
97 StereoCameraModel stereoModel_;
98 bool rightGrayScale_;
99 std::vector<StereoCameraModel> multiStereoModels_; // sub-camera stereo models shared by all frames (multi-camera mode); empty when loaded per-frame
100};
101
102
103} // namespace rtabmap
virtual std::string getSerial() const
Returns the sensor's serial number or unique identifier.
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
Initializes the sensor.
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53