SensorData.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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(); // empty constructor
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         // Metric constructor
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         // Metric constructor + 2d laser scan
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         // use isValid() instead
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         // Metric stuff
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         // features
00141         std::vector<cv::KeyPoint> _keypoints;
00142         cv::Mat _descriptors;
00143 
00144         // user data
00145         std::vector<unsigned char> _userData;
00146 };
00147 
00148 }
00149 
00150 
00151 #endif /* SENSORDATA_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Fri Aug 28 2015 12:51:32