Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SENSORDATA_H_
00029 #define SENSORDATA_H_
00030
00031 #include <rtabmap/core/RtabmapExp.h>
00032 #include <rtabmap/core/Transform.h>
00033 #include <opencv2/core/core.hpp>
00034 #include <opencv2/features2d/features2d.hpp>
00035
00036 namespace rtabmap
00037 {
00038
00042 class RTABMAP_EXP SensorData
00043 {
00044 public:
00045 SensorData();
00046 SensorData(const cv::Mat & image, int id = 0, double stamp = 0.0, const std::vector<unsigned char> & userData = std::vector<unsigned char>());
00047
00048
00049 SensorData(const cv::Mat & image,
00050 const cv::Mat & depthOrRightImage,
00051 float fx,
00052 float fyOrBaseline,
00053 float cx,
00054 float cy,
00055 const Transform & localTransform,
00056 const Transform & pose,
00057 float poseRotVariance,
00058 float poseTransVariance,
00059 int id,
00060 double stamp,
00061 const std::vector<unsigned char> & userData = std::vector<unsigned char>());
00062
00063
00064 SensorData(const cv::Mat & laserScan,
00065 int laserScanMaxPts,
00066 const cv::Mat & image,
00067 const cv::Mat & depthOrRightImage,
00068 float fx,
00069 float fyOrBaseline,
00070 float cx,
00071 float cy,
00072 const Transform & localTransform,
00073 const Transform & pose,
00074 float poseRotVariance,
00075 float poseTransVariance,
00076 int id,
00077 double stamp,
00078 const std::vector<unsigned char> & userData = std::vector<unsigned char>());
00079
00080 virtual ~SensorData() {}
00081
00082 bool isValid() const {return !_image.empty();}
00083
00084
00085 RTABMAP_DEPRECATED(bool empty() const, "Use !isValid() instead.");
00086
00087 const cv::Mat & image() const {return _image;}
00088 int id() const {return _id;}
00089 void setId(int id) {_id = id;}
00090 double stamp() const {return _stamp;}
00091 void setStamp(double stamp) {_stamp = stamp;}
00092
00093 bool isMetric() const {return !_depthOrRightImage.empty() || _fx != 0.0f || _fyOrBaseline != 0.0f || !_pose.isNull();}
00094 void setPose(const Transform & pose, float rotVariance, float transVariance) {_pose = pose; _poseRotVariance=rotVariance; _poseTransVariance = transVariance;}
00095 cv::Mat depth() const {return (_depthOrRightImage.type()==CV_32FC1 || _depthOrRightImage.type()==CV_16UC1)?_depthOrRightImage:cv::Mat();}
00096 cv::Mat rightImage() const {return _depthOrRightImage.type()==CV_8UC1?_depthOrRightImage:cv::Mat();}
00097 const cv::Mat & depthOrRightImage() const {return _depthOrRightImage;}
00098 const cv::Mat & laserScan() const {return _laserScan;}
00099 int laserScanMaxPts() const {return _laserScanMaxPts;}
00100 float fx() const {return _fx;}
00101 float fy() const {return (_depthOrRightImage.type()==CV_8UC1)?0:_fyOrBaseline;}
00102 float cx() const {return _cx;}
00103 float cy() const {return _cy;}
00104 float baseline() const {return _depthOrRightImage.type()==CV_8UC1?_fyOrBaseline:0;}
00105 float fyOrBaseline() const {return _fyOrBaseline;}
00106 const Transform & pose() const {return _pose;}
00107 const Transform & localTransform() const {return _localTransform;}
00108 float poseRotVariance() const {return _poseRotVariance;}
00109 float poseTransVariance() const {return _poseTransVariance;}
00110
00111 void setFeatures(const std::vector<cv::KeyPoint> & keypoints, const cv::Mat & descriptors)
00112 {
00113 _keypoints = keypoints;
00114 _descriptors = descriptors;
00115 }
00116 const std::vector<cv::KeyPoint> & keypoints() const {return _keypoints;}
00117 const cv::Mat & descriptors() const {return _descriptors;}
00118
00119 void setUserData(const std::vector<unsigned char> & data) {_userData = data;}
00120 const std::vector<unsigned char> & userData() const {return _userData;}
00121
00122 private:
00123 cv::Mat _image;
00124 int _id;
00125 double _stamp;
00126
00127
00128 cv::Mat _depthOrRightImage;
00129 cv::Mat _laserScan;
00130 float _fx;
00131 float _fyOrBaseline;
00132 float _cx;
00133 float _cy;
00134 Transform _pose;
00135 Transform _localTransform;
00136 float _poseRotVariance;
00137 float _poseTransVariance;
00138 int _laserScanMaxPts;
00139
00140
00141 std::vector<cv::KeyPoint> _keypoints;
00142 cv::Mat _descriptors;
00143
00144
00145 std::vector<unsigned char> _userData;
00146 };
00147
00148 }
00149
00150
00151 #endif