mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Memory efficiency: changed std::vector<unsigned char> bytes arrays to cv::Mat to avoid multiple copies when Signature objects are copied.
git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1937 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
@@ -96,8 +96,8 @@ public:
|
||||
|
||||
// Specific queries...
|
||||
void loadNodeData(std::list<Signature *> & signatures, bool loadMetricData) const;
|
||||
void getNodeData(int signatureId, std::vector<unsigned char> & image, std::vector<unsigned char> & depth, std::vector<unsigned char> & depth2d, float & fx, float & fy, float & cx, float & cy, Transform & localTransform) const;
|
||||
void getNodeData(int signatureId, std::vector<unsigned char> & image) const;
|
||||
void getNodeData(int signatureId, cv::Mat & imageCompressed, cv::Mat & depthCompressed, cv::Mat & depth2dCompressed, float & fx, float & fy, float & cx, float & cy, Transform & localTransform) const;
|
||||
void getNodeData(int signatureId, cv::Mat & imageCompressed) const;
|
||||
void getPose(int signatureId, Transform & pose, int & mapId) const;
|
||||
void loadNeighbors(int signatureId, std::map<int, Transform> & neighbors) const;
|
||||
void loadLoopClosures(int signatureId, std::map<int, Transform> & loopIds, std::map<int, Transform> & childIds) const;
|
||||
@@ -135,8 +135,8 @@ private:
|
||||
virtual void loadLoopClosuresQuery(int signatureId, std::map<int, Transform> & loopIds, std::map<int, Transform> & childIds) const = 0;
|
||||
|
||||
virtual void loadNodeDataQuery(std::list<Signature *> & signatures, bool loadMetricData) const = 0;
|
||||
virtual void getNodeDataQuery(int signatureId, std::vector<unsigned char> & image, std::vector<unsigned char> & depth, std::vector<unsigned char> & depth2d, float & fx, float & fy, float & cx, float & cy, Transform & localTransform) const = 0;
|
||||
virtual void getNodeDataQuery(int signatureId, std::vector<unsigned char> & image) const = 0;
|
||||
virtual void getNodeDataQuery(int signatureId, cv::Mat & imageCompressed, cv::Mat & depthCompressed, cv::Mat & depth2dCompressed, float & fx, float & fy, float & cx, float & cy, Transform & localTransform) const = 0;
|
||||
virtual void getNodeDataQuery(int signatureId, cv::Mat & imageCompressed) const = 0;
|
||||
virtual void getPoseQuery(int signatureId, Transform & pose, int & mapId) const = 0;
|
||||
virtual void getAllNodeIdsQuery(std::set<int> & ids, bool ignoreChildren) const = 0;
|
||||
virtual void getLastIdQuery(const std::string & tableName, int & id) const = 0;
|
||||
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
int getDatabaseMemoryUsed() const; // in bytes
|
||||
double getDbSavingTime() const;
|
||||
int getMapId(int signatureId) const;
|
||||
std::vector<unsigned char> getImage(int signatureId) const;
|
||||
cv::Mat getImageCompressed(int signatureId) const;
|
||||
Signature getSignatureData(int locationId, bool uncompressedData = false);
|
||||
std::set<int> getAllSignatureIds() const;
|
||||
bool memoryChanged() const {return _memoryChanged;}
|
||||
|
||||
@@ -56,9 +56,9 @@ public:
|
||||
const std::multimap<int, cv::KeyPoint> & words,
|
||||
const std::multimap<int, pcl::PointXYZ> & words3,
|
||||
const Transform & pose = Transform(),
|
||||
const std::vector<unsigned char> & depth2D = std::vector<unsigned char>(),
|
||||
const std::vector<unsigned char> & image = std::vector<unsigned char>(),
|
||||
const std::vector<unsigned char> & depth = std::vector<unsigned char>(),
|
||||
const cv::Mat & depth2D = cv::Mat(),
|
||||
const cv::Mat & image = cv::Mat(),
|
||||
const cv::Mat & depth = cv::Mat(),
|
||||
float fx = 0.0f,
|
||||
float fy = 0.0f,
|
||||
float cx = 0.0f,
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
/**
|
||||
* Must return a value between >=0 and <=1 (1 means 100% similarity).
|
||||
*/
|
||||
float compareTo(const Signature * signature) const;
|
||||
float compareTo(const Signature & signature) const;
|
||||
bool isBadSignature() const;
|
||||
|
||||
int id() const {return _id;}
|
||||
@@ -113,20 +113,20 @@ public:
|
||||
void setEnabled(bool enabled) {_enabled = enabled;}
|
||||
const std::multimap<int, cv::KeyPoint> & getWords() const {return _words;}
|
||||
const std::map<int, int> & getWordsChanged() const {return _wordsChanged;}
|
||||
void setImage(const std::vector<unsigned char> & image) {_image = image;}
|
||||
const std::vector<unsigned char> & getImage() const {return _image;}
|
||||
void setImageCompressed(const cv::Mat & bytes) {_imageCompressed = bytes;}
|
||||
const cv::Mat & getImageCompressed() const {return _imageCompressed;}
|
||||
void setImageRaw(const cv::Mat & image) {_imageRaw = image;}
|
||||
const cv::Mat & getImageRaw() const {return _imageRaw;}
|
||||
|
||||
//metric stuff
|
||||
void setWords3(const std::multimap<int, pcl::PointXYZ> & words3) {_words3 = words3;}
|
||||
void setDepth(const std::vector<unsigned char> & depth, float fx, float fy, float cx, float cy);
|
||||
void setDepth2D(const std::vector<unsigned char> & depth2D) {_depth2D = depth2D;}
|
||||
void setDepthCompressed(const cv::Mat & bytes, float fx, float fy, float cx, float cy);
|
||||
void setDepth2DCompressed(const cv::Mat & bytes) {_depth2DCompressed = bytes;}
|
||||
void setLocalTransform(const Transform & t) {_localTransform = t;}
|
||||
void setPose(const Transform & pose) {_pose = pose;}
|
||||
const std::multimap<int, pcl::PointXYZ> & getWords3() const {return _words3;}
|
||||
const std::vector<unsigned char> & getDepth() const {return _depth;}
|
||||
const std::vector<unsigned char> & getDepth2D() const {return _depth2D;}
|
||||
const cv::Mat & getDepthCompressed() const {return _depthCompressed;}
|
||||
const cv::Mat & getDepth2DCompressed() const {return _depth2DCompressed;}
|
||||
float getDepthFx() const {return _fx;}
|
||||
float getDepthFy() const {return _fy;}
|
||||
float getDepthCx() const {return _cx;}
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
|
||||
SensorData toSensorData();
|
||||
void uncompressData();
|
||||
void uncompressData(cv::Mat * image, cv::Mat * depth, cv::Mat * depth2D) const;
|
||||
void uncompressData(cv::Mat * imageRaw, cv::Mat * depthRaw, cv::Mat * depth2DRaw) const;
|
||||
|
||||
private:
|
||||
int _id;
|
||||
@@ -159,10 +159,10 @@ private:
|
||||
std::multimap<int, cv::KeyPoint> _words; // word <id, keypoint>
|
||||
std::map<int, int> _wordsChanged; // <oldId, newId>
|
||||
bool _enabled;
|
||||
std::vector<unsigned char> _image; //compressed image CV_8UC1 or CV_8UC3
|
||||
cv::Mat _imageCompressed; // compressed image
|
||||
|
||||
std::vector<unsigned char> _depth; // compressed image CV_16UC1
|
||||
std::vector<unsigned char> _depth2D; // compressed data CV_32FC2
|
||||
cv::Mat _depthCompressed; // compressed image
|
||||
cv::Mat _depth2DCompressed; // compressed data
|
||||
float _fx;
|
||||
float _fy;
|
||||
float _cx;
|
||||
@@ -171,9 +171,9 @@ private:
|
||||
Transform _localTransform; // camera_link -> base_link
|
||||
std::multimap<int, pcl::PointXYZ> _words3; // word <id, keypoint>
|
||||
|
||||
cv::Mat _imageRaw;
|
||||
cv::Mat _depthRaw;
|
||||
cv::Mat _depth2DRaw;
|
||||
cv::Mat _imageRaw; // CV_8UC1 or CV_8UC3
|
||||
cv::Mat _depthRaw; // depth CV_16UC1 or CV_32FC1, right image CV_8UC1
|
||||
cv::Mat _depth2DRaw; // CV_32FC2
|
||||
};
|
||||
|
||||
} // namespace rtabmap
|
||||
|
||||
@@ -71,14 +71,13 @@ class RTABMAP_EXP CompressionThread : public UThread
|
||||
public:
|
||||
// format : ".png" ".jpg" "" (empty is general)
|
||||
CompressionThread(const cv::Mat & mat, const std::string & format = "");
|
||||
CompressionThread(const std::vector<unsigned char> * bytes, bool isImage);
|
||||
const std::vector<unsigned char> & getCompressedData() const {return compressedData_;}
|
||||
CompressionThread(const cv::Mat & bytes, bool isImage);
|
||||
const cv::Mat & getCompressedData() const {return compressedData_;}
|
||||
cv::Mat & getUncompressedData() {return uncompressedData_;}
|
||||
protected:
|
||||
virtual void mainLoop();
|
||||
private:
|
||||
const std::vector<unsigned char> * constCompressedData_;
|
||||
std::vector<unsigned char> compressedData_;
|
||||
cv::Mat compressedData_;
|
||||
cv::Mat uncompressedData_;
|
||||
std::string format_;
|
||||
bool image_;
|
||||
@@ -235,10 +234,17 @@ cv::Mat RTABMAP_EXP depth2DFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> &
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_EXP depth2DToPointCloud(const cv::Mat & depth2D);
|
||||
|
||||
std::vector<unsigned char> RTABMAP_EXP compressImage(const cv::Mat & image, const std::string & format = ".png");
|
||||
cv::Mat RTABMAP_EXP compressImage2(const cv::Mat & image, const std::string & format = ".png");
|
||||
|
||||
cv::Mat RTABMAP_EXP uncompressImage(const cv::Mat & bytes);
|
||||
cv::Mat RTABMAP_EXP uncompressImage(const std::vector<unsigned char> & bytes);
|
||||
|
||||
std::vector<unsigned char> RTABMAP_EXP compressData(const cv::Mat & data);
|
||||
cv::Mat RTABMAP_EXP compressData2(const cv::Mat & data);
|
||||
|
||||
cv::Mat RTABMAP_EXP uncompressData(const cv::Mat & bytes);
|
||||
cv::Mat RTABMAP_EXP uncompressData(const std::vector<unsigned char> & bytes);
|
||||
cv::Mat RTABMAP_EXP uncompressData(const unsigned char * bytes, unsigned long size);
|
||||
|
||||
// remove depth by z axis
|
||||
void RTABMAP_EXP extractXYZCorrespondences(const std::multimap<int, pcl::PointXYZ> & words1,
|
||||
|
||||
Reference in New Issue
Block a user