CameraMobile.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 #ifndef CAMERAMOBILE_H_
29 #define CAMERAMOBILE_H_
30 
31 #include <rtabmap/core/Camera.h>
33 #include <rtabmap/utilite/UMutex.h>
37 #include <rtabmap/utilite/UEvent.h>
38 #include <rtabmap/utilite/UTimer.h>
39 #include <boost/thread/mutex.hpp>
40 #include "util.h"
41 
42 namespace rtabmap {
43 
44 class CameraInfoEvent: public UEvent
45 {
46 public:
47  CameraInfoEvent(int type, const std::string & key, const std::string & value) : type_(type), key_(key), value_(value) {}
48  virtual std::string getClassName() const {return "CameraInfoEvent";}
49  int type() const {return type_;}
50  const std::string & key() const {return key_;}
51  const std::string & value() const {return value_;}
52 
53 private:
54  int type_;
55  std::string key_;
56  std::string value_;
57 
58 };
59 
60 class PoseEvent: public UEvent
61 {
62 public:
64  virtual std::string getClassName() const {return "PoseEvent";}
65  const Transform & pose() const {return pose_;}
66 
67 private:
69 };
70 
71 class CameraMobile : public Camera, public UEventsSender {
72 public:
73  static const float bilateralFilteringSigmaS;
74  static const float bilateralFilteringSigmaR;
75 
78 
79 public:
81  const cv::Mat & pointCloudData,
82  int points,
83  const Transform & pose,
84  const CameraModel & model,
85  const cv::Mat & rgb,
86  std::vector<cv::KeyPoint> * kpts = 0,
87  std::vector<cv::Point3f> * kpts3D = 0,
88  int kptsSize = 3);
89 
90 public:
91  CameraMobile(bool smoothing = false);
92  virtual ~CameraMobile();
93 
94  // abstract functions
95  virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
96  virtual void close(); // inherited classes should call its parent at the end of their close().
97  virtual std::string getSerial() const {return "CameraMobile";}
98 
99  void update(const SensorData & data, const Transform & pose, const glm::mat4 & viewMatrix, const glm::mat4 & projectionMatrix, const float * texCoord);
100  void updateOnRender();
101 
102  const Transform & getOriginOffset() const {return originOffset_;} // in rtabmap frame
103  void resetOrigin();
104  virtual bool isCalibrated() const;
105 
106  virtual bool odomProvided() const { return true; }
107  virtual bool getPose(double epochStamp, Transform & pose, cv::Mat & covariance, double maxWaitTime = 0.06); // Return pose of device in rtabmap frame (with origin offset), stamp should be epoch time
108  void poseReceived(const Transform & pose, double deviceStamp); // original pose of device in rtabmap frame (without origin offset), stamp of the device (may be not epoch)
109  double getStampEpochOffset() const {return stampEpochOffset_;}
110 
111  const CameraModel & getCameraModel() const {return model_;}
113  void setSmoothing(bool enabled) {smoothing_ = enabled;}
114  virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height) {colorCameraToDisplayRotation_ = colorCameraToDisplayRotation;}
115  void setGPS(const GPS & gps);
116  void addEnvSensor(int type, float value);
117 
119  bool uvsInitialized() const {return uvs_initialized_;}
120  const float* uvsTransformed() const {return transformed_uvs_;}
123 
124  void setOcclusionImage(const cv::Mat & image, const CameraModel & model) {occlusionModel_ = model; occlusionImage_ = image;}
125  const cv::Mat & getOcclusionImage(CameraModel * model=0) const {if(model)*model=occlusionModel_; return occlusionImage_; }
126 
127 protected:
128  virtual SensorData updateDataOnRender(Transform & pose);
129 
130 private:
131  virtual SensorData captureImage(SensorCaptureInfo * info = 0);
132  void postUpdate(); // Should be called while being protected by dataMutex_
133 
134 protected:
135  CameraModel model_; // local transform is the device to camera optical rotation in rtabmap frame
136  Transform deviceTColorCamera_; // device to camera optical rotation in rtabmap frame
137 
142  bool uvs_initialized_ = false;
143 
144 private:
153 
158 
160  std::map<double, Transform> poseBuffer_; // <stamp, Pose>
161 
164 };
165 
166 } /* namespace rtabmap */
167 #endif /* CAMERATANGO_H_ */
rtabmap::SensorData
Definition: SensorData.h:51
rtabmap::CameraMobile::scanFromPointCloudData
static LaserScan scanFromPointCloudData(const cv::Mat &pointCloudData, int points, const Transform &pose, const CameraModel &model, const cv::Mat &rgb, std::vector< cv::KeyPoint > *kpts=0, std::vector< cv::Point3f > *kpts3D=0, int kptsSize=3)
Definition: CameraMobile.cpp:461
rtabmap::CameraMobile::postUpdate
void postUpdate()
Definition: CameraMobile.cpp:308
rtabmap::CameraInfoEvent::key
const std::string & key() const
Definition: CameraMobile.h:50
rtabmap::CameraMobile::close
virtual void close()
Definition: CameraMobile.cpp:78
rtabmap::CameraMobile::poseMutex_
UMutex poseMutex_
Definition: CameraMobile.h:159
rtabmap::CameraMobile::captureImage
virtual SensorData captureImage(SensorCaptureInfo *info=0)
Definition: CameraMobile.cpp:424
rtabmap::CameraMobile::getTextureId
GLuint getTextureId()
Definition: CameraMobile.h:118
rtabmap::CameraMobile::isCalibrated
virtual bool isCalibrated() const
Definition: CameraMobile.cpp:201
rtabmap::CameraMobile::colorCameraToDisplayRotation_
ScreenRotation colorCameraToDisplayRotation_
Definition: CameraMobile.h:148
rtabmap::PoseEvent::pose
const Transform & pose() const
Definition: CameraMobile.h:65
rtabmap::CameraMobile::projectionMatrix_
glm::mat4 projectionMatrix_
Definition: CameraMobile.h:140
rtabmap::CameraMobile::setGPS
void setGPS(const GPS &gps)
Definition: CameraMobile.cpp:206
rtabmap::CameraMobile::getOriginOffset
const Transform & getOriginOffset() const
Definition: CameraMobile.h:102
rtabmap::CameraMobile::occlusionModel_
CameraModel occlusionModel_
Definition: CameraMobile.h:163
rtabmap::CameraModel
Definition: CameraModel.h:38
projection
Expression< Point2 > projection(f, p_cam)
rtabmap::CameraMobile::getSerial
virtual std::string getSerial() const
Definition: CameraMobile.h:97
rtabmap::CameraMobile::dataPose_
Transform dataPose_
Definition: CameraMobile.h:157
GeodeticCoords.h
rtabmap::GPS
Definition: GPS.h:35
type
rtabmap::CameraMobile::dataMutex_
UMutex dataMutex_
Definition: CameraMobile.h:155
rtabmap::CameraMobile::uvsInitialized
bool uvsInitialized() const
Definition: CameraMobile.h:119
rtabmap::CameraMobile::transformed_uvs_
float transformed_uvs_[8]
Definition: CameraMobile.h:141
rtabmap::CameraMobile::uvs_initialized_
bool uvs_initialized_
Definition: CameraMobile.h:142
rtabmap::PoseEvent
Definition: CameraMobile.h:60
rtabmap::CameraInfoEvent::getClassName
virtual std::string getClassName() const
Definition: CameraMobile.h:48
rtabmap::CameraMobile::addEnvSensor
void addEnvSensor(int type, float value)
Definition: CameraMobile.cpp:211
rtabmap::CameraMobile::setSmoothing
void setSmoothing(bool enabled)
Definition: CameraMobile.h:113
rtabmap::CameraMobile::viewMatrix_
glm::mat4 viewMatrix_
Definition: CameraMobile.h:139
rtabmap::LaserScan
Definition: LaserScan.h:37
rtabmap::CameraMobile::deviceTColorCamera_
Transform deviceTColorCamera_
Definition: CameraMobile.h:136
UTimer.h
glm::detail::tmat4x4
Definition: type_mat.hpp:47
UEvent
Definition: UEvent.h:57
rtabmap::SensorCaptureInfo
Definition: SensorCaptureInfo.h:36
view
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set view
rtabmap::CameraMobile::smoothing_
bool smoothing_
Definition: CameraMobile.h:147
rtabmap::CameraMobile::lastKnownGPS_
GPS lastKnownGPS_
Definition: CameraMobile.h:149
UEvent.h
GLuint
unsigned int GLuint
Definition: dummy.cpp:78
rtabmap::CameraMobile::textureId_
GLuint textureId_
Definition: CameraMobile.h:138
UMutex
Definition: UMutex.h:54
rtabmap::CameraMobile::getScreenRotation
ScreenRotation getScreenRotation() const
Definition: CameraMobile.h:122
rtabmap::CameraMobile::lastEnvSensors_
EnvSensors lastEnvSensors_
Definition: CameraMobile.h:150
rtabmap::CameraMobile::update
void update(const SensorData &data, const Transform &pose, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix, const float *texCoord)
Definition: CameraMobile.cpp:216
rtabmap::CameraMobile::occlusionImage_
cv::Mat occlusionImage_
Definition: CameraMobile.h:162
UMutex.h
rtabmap::CameraMobile::getPose
virtual bool getPose(double epochStamp, Transform &pose, cv::Mat &covariance, double maxWaitTime=0.06)
Definition: CameraMobile.cpp:105
rtabmap::CameraInfoEvent::key_
std::string key_
Definition: CameraMobile.h:55
rtabmap::PoseEvent::getClassName
virtual std::string getClassName() const
Definition: CameraMobile.h:64
rtabmap::CameraMobile::init
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
Definition: CameraMobile.cpp:72
rtabmap::CameraMobile::resetOrigin
void resetOrigin()
Definition: CameraMobile.cpp:95
rtabmap::CameraMobile::opticalRotation
static const rtabmap::Transform opticalRotation
Definition: CameraMobile.h:76
rtabmap::Camera
Definition: Camera.h:43
rtabmap::CameraMobile::updateOnRender
void updateOnRender()
Definition: CameraMobile.cpp:283
rtabmap::CameraMobile::dataReady_
USemaphore dataReady_
Definition: CameraMobile.h:154
rtabmap::CameraMobile::poseReceived
void poseReceived(const Transform &pose, double deviceStamp)
Definition: CameraMobile.cpp:164
rtabmap::CameraMobile::CameraMobile
CameraMobile(bool smoothing=false)
Definition: CameraMobile.cpp:55
rtabmap::CameraMobile::setScreenRotationAndSize
virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height)
Definition: CameraMobile.h:114
rtabmap::PoseEvent::pose_
Transform pose_
Definition: CameraMobile.h:68
rtabmap::CameraMobile::getVPMatrices
void getVPMatrices(glm::mat4 &view, glm::mat4 &projection) const
Definition: CameraMobile.h:121
UEventsSender.h
rtabmap::Transform
Definition: Transform.h:41
rtabmap::CameraMobile::updateDataOnRender
virtual SensorData updateDataOnRender(Transform &pose)
Definition: CameraMobile.cpp:301
rtabmap::PoseEvent::PoseEvent
PoseEvent(const Transform &pose)
Definition: CameraMobile.h:63
rtabmap::EnvSensors
std::map< EnvSensor::Type, EnvSensor > EnvSensors
Definition: EnvSensor.h:81
rtabmap::CameraMobile::getStampEpochOffset
double getStampEpochOffset() const
Definition: CameraMobile.h:109
rtabmap::CameraMobile::getOcclusionImage
const cv::Mat & getOcclusionImage(CameraModel *model=0) const
Definition: CameraMobile.h:125
rtabmap::ScreenRotation
ScreenRotation
Definition: util.h:194
rtabmap::CameraMobile::bilateralFilteringSigmaS
static const float bilateralFilteringSigmaS
Definition: CameraMobile.h:73
USemaphore
Definition: USemaphore.h:54
rtabmap::CameraMobile::uvsTransformed
const float * uvsTransformed() const
Definition: CameraMobile.h:120
USemaphore.h
rtabmap::CameraInfoEvent::value_
std::string value_
Definition: CameraMobile.h:56
UThread.h
rtabmap::CameraMobile
Definition: CameraMobile.h:71
rtabmap::CameraInfoEvent
Definition: CameraMobile.h:44
rtabmap::CameraMobile::data_
SensorData data_
Definition: CameraMobile.h:156
rtabmap::CameraMobile::bilateralFilteringSigmaR
static const float bilateralFilteringSigmaR
Definition: CameraMobile.h:74
rtabmap::CameraInfoEvent::type_
int type_
Definition: CameraMobile.h:54
Camera.h
rtabmap::CameraMobile::getDeviceTColorCamera
const Transform & getDeviceTColorCamera() const
Definition: CameraMobile.h:112
rtabmap::CameraMobile::opticalRotationInv
static const rtabmap::Transform opticalRotationInv
Definition: CameraMobile.h:77
rtabmap::CameraMobile::originUpdate_
bool originUpdate_
Definition: CameraMobile.h:152
rtabmap::CameraMobile::model_
CameraModel model_
Definition: CameraMobile.h:135
rtabmap::CameraMobile::setOcclusionImage
void setOcclusionImage(const cv::Mat &image, const CameraModel &model)
Definition: CameraMobile.h:124
rtabmap::CameraInfoEvent::value
const std::string & value() const
Definition: CameraMobile.h:51
rtabmap::CameraInfoEvent::CameraInfoEvent
CameraInfoEvent(int type, const std::string &key, const std::string &value)
Definition: CameraMobile.h:47
rtabmap::CameraMobile::~CameraMobile
virtual ~CameraMobile()
Definition: CameraMobile.cpp:67
rtabmap::CameraMobile::odomProvided
virtual bool odomProvided() const
Definition: CameraMobile.h:106
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::CameraInfoEvent::type
int type() const
Definition: CameraMobile.h:49
util.h
trace.model
model
Definition: trace.py:4
rtabmap::CameraMobile::getCameraModel
const CameraModel & getCameraModel() const
Definition: CameraMobile.h:111
rtabmap::CameraMobile::firstFrame_
bool firstFrame_
Definition: CameraMobile.h:145
rtabmap::CameraMobile::originOffset_
Transform originOffset_
Definition: CameraMobile.h:151
UEventsSender
Definition: UEventsSender.h:15
rtabmap::CameraMobile::poseBuffer_
std::map< double, Transform > poseBuffer_
Definition: CameraMobile.h:160
rtabmap::CameraMobile::stampEpochOffset_
double stampEpochOffset_
Definition: CameraMobile.h:146


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