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:
63  PoseEvent(const Transform & pose) : pose_(pose) {}
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 UThread, public UEventsSender {
72 public:
73  static const float bilateralFilteringSigmaS;
74  static const float bilateralFilteringSigmaR;
75 
78 
79 public:
80  static LaserScan scanFromPointCloudData(
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 in their close().
97  virtual std::string getSerial() const {return "CameraMobile";}
98 
99  const Transform & getOriginOffset() const {return originOffset_;} // in rtabmap frame
100  void resetOrigin();
101  virtual bool isCalibrated() const;
102 
103  void poseReceived(const Transform & pose); // in rtabmap frame
104 
105  const CameraModel & getCameraModel() const {return model_;}
106  const Transform & getDeviceTColorCamera() const {return deviceTColorCamera_;}
107  void setSmoothing(bool enabled) {smoothing_ = enabled;}
108  virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height) {colorCameraToDisplayRotation_ = colorCameraToDisplayRotation;}
109  void setGPS(const GPS & gps);
110  void addEnvSensor(int type, float value);
111  void setData(const SensorData & data, const Transform & pose, const glm::mat4 & viewMatrix, const glm::mat4 & projectionMatrix, const float * texCoord);
112 
113  void spinOnce(); // Should only be called if not thread is not running, otherwise it does nothing
114 
115  GLuint getTextureId() {return textureId_;}
116  bool uvsInitialized() const {return uvs_initialized_;}
117  const float* uvsTransformed() const {return transformed_uvs_;}
118  void getVPMatrices(glm::mat4 & view, glm::mat4 & projection) const {view=viewMatrix_; projection=projectionMatrix_;}
119  ScreenRotation getScreenRotation() const {return colorCameraToDisplayRotation_;}
120 
121  void setOcclusionImage(const cv::Mat & image, const CameraModel & model) {occlusionModel_ = model; occlusionImage_ = image;}
122  const cv::Mat & getOcclusionImage(CameraModel * model=0) const {if(model)*model=occlusionModel_; return occlusionImage_; }
123 
124 protected:
125  virtual SensorData captureImage(CameraInfo * info = 0);
126  virtual void capturePoseOnly() {}
127 
128  virtual void mainLoopBegin();
129  virtual void mainLoop();
130 
131 protected:
132  CameraModel model_; // local transform is the device to camera optical rotation in rtabmap frame
133  Transform deviceTColorCamera_; // device to camera optical rotation in rtabmap frame
136 
140  float transformed_uvs_[8];
141  bool uvs_initialized_ = false;
142 
143 private:
154 
157 
160 };
161 
162 } /* namespace rtabmap */
163 #endif /* CAMERATANGO_H_ */
virtual std::string getSerial() const
Definition: CameraMobile.h:97
Definition: UTimer.h:46
const Transform & pose() const
Definition: CameraMobile.h:65
const Transform & getOriginOffset() const
Definition: CameraMobile.h:99
Definition: UEvent.h:57
void setSmoothing(bool enabled)
Definition: CameraMobile.h:107
ScreenRotation colorCameraToDisplayRotation_
Definition: CameraMobile.h:149
def init(descriptorDim, matchThreshold, iterations, cuda, model_path)
bool uvsInitialized() const
Definition: CameraMobile.h:116
CameraModel occlusionModel_
Definition: CameraMobile.h:159
data
unsigned int GLuint
Definition: dummy.cpp:78
Transform deviceTColorCamera_
Definition: CameraMobile.h:133
virtual std::string getClassName() const
Definition: CameraMobile.h:48
CameraInfoEvent(int type, const std::string &key, const std::string &value)
Definition: CameraMobile.h:47
EnvSensors lastEnvSensors_
Definition: CameraMobile.h:151
static const float bilateralFilteringSigmaS
Definition: CameraMobile.h:73
virtual void capturePoseOnly()
Definition: CameraMobile.h:126
virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height)
Definition: CameraMobile.h:108
ScreenRotation getScreenRotation() const
Definition: CameraMobile.h:119
PoseEvent(const Transform &pose)
Definition: CameraMobile.h:63
const Transform & getDeviceTColorCamera() const
Definition: CameraMobile.h:106
const cv::Mat & getOcclusionImage(CameraModel *model=0) const
Definition: CameraMobile.h:122
static const rtabmap::Transform opticalRotation
Definition: CameraMobile.h:76
static const float bilateralFilteringSigmaR
Definition: CameraMobile.h:74
const CameraModel & getCameraModel() const
Definition: CameraMobile.h:105
const float * uvsTransformed() const
Definition: CameraMobile.h:117
void setOcclusionImage(const cv::Mat &image, const CameraModel &model)
Definition: CameraMobile.h:121
void getVPMatrices(glm::mat4 &view, glm::mat4 &projection) const
Definition: CameraMobile.h:118
model
Definition: trace.py:4
std::map< EnvSensor::Type, EnvSensor > EnvSensors
Definition: EnvSensor.h:81
static const rtabmap::Transform opticalRotationInv
Definition: CameraMobile.h:77
virtual std::string getClassName() const
Definition: CameraMobile.h:64
ScreenRotation
Definition: util.h:194
const std::string & value() const
Definition: CameraMobile.h:51
glm::mat4 projectionMatrix_
Definition: CameraMobile.h:139
const std::string & key() const
Definition: CameraMobile.h:50


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