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  CameraMobile(bool smoothing = false);
81  virtual ~CameraMobile();
82 
83  // abstract functions
84  virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "");
85  virtual void close(); // inherited classes should call its parent in their close().
86  virtual std::string getSerial() const {return "CameraMobile";}
87 
88  const Transform & getOriginOffset() const {return originOffset_;} // in rtabmap frame
89  void resetOrigin();
90  virtual bool isCalibrated() const;
91 
92  void poseReceived(const Transform & pose); // in rtabmap frame
93 
94  const CameraModel & getCameraModel() const {return model_;}
95  const Transform & getDeviceTColorCamera() const {return deviceTColorCamera_;}
96  void setSmoothing(bool enabled) {smoothing_ = enabled;}
97  virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height) {colorCameraToDisplayRotation_ = colorCameraToDisplayRotation;}
98  void setGPS(const GPS & gps);
99  void addEnvSensor(int type, float value);
100  void setData(const SensorData & data, const Transform & pose);
101 
102  void spinOnce(); // Should only be called if not thread is not running, otherwise it does nothing
103 
104 protected:
105  virtual SensorData captureImage(CameraInfo * info = 0);
106  virtual void capturePoseOnly() {}
107 
108  virtual void mainLoopBegin();
109  virtual void mainLoop();
110 
111 protected:
112  CameraModel model_; // local transform is the device to camera optical rotation in rtabmap frame
113  Transform deviceTColorCamera_; // device to camera optical rotation in rtabmap frame
116 
117 private:
128 
131 };
132 
133 } /* namespace rtabmap */
134 #endif /* CAMERATANGO_H_ */
const std::string & value() const
Definition: CameraMobile.h:51
Definition: UTimer.h:46
virtual std::string getClassName() const
Definition: CameraMobile.h:64
Definition: UEvent.h:57
void setSmoothing(bool enabled)
Definition: CameraMobile.h:96
ScreenRotation colorCameraToDisplayRotation_
Definition: CameraMobile.h:123
const Transform & getOriginOffset() const
Definition: CameraMobile.h:88
def init(descriptorDim, matchThreshold, iterations, cuda, model_path)
const Transform & pose() const
Definition: CameraMobile.h:65
virtual std::string getClassName() const
Definition: CameraMobile.h:48
Transform deviceTColorCamera_
Definition: CameraMobile.h:113
virtual std::string getSerial() const
Definition: CameraMobile.h:86
CameraInfoEvent(int type, const std::string &key, const std::string &value)
Definition: CameraMobile.h:47
EnvSensors lastEnvSensors_
Definition: CameraMobile.h:125
static const float bilateralFilteringSigmaS
Definition: CameraMobile.h:73
virtual void capturePoseOnly()
Definition: CameraMobile.h:106
virtual void setScreenRotationAndSize(ScreenRotation colorCameraToDisplayRotation, int width, int height)
Definition: CameraMobile.h:97
PoseEvent(const Transform &pose)
Definition: CameraMobile.h:63
static const rtabmap::Transform opticalRotation
Definition: CameraMobile.h:76
static const float bilateralFilteringSigmaR
Definition: CameraMobile.h:74
const CameraModel & getCameraModel() const
Definition: CameraMobile.h:94
const Transform & getDeviceTColorCamera() const
Definition: CameraMobile.h:95
std::map< EnvSensor::Type, EnvSensor > EnvSensors
Definition: EnvSensor.h:81
static const rtabmap::Transform opticalRotationInv
Definition: CameraMobile.h:77
ScreenRotation
Definition: util.h:192
const std::string & key() const
Definition: CameraMobile.h:50


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:58