49 const cv::Mat & image,
52 const cv::Mat & userData) :
59 UASSERT(image.type() == CV_8UC1);
62 else if(!image.empty())
64 UASSERT(image.type() == CV_8UC1 ||
65 image.type() == CV_8UC3);
69 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
81 const cv::Mat & image,
85 const cv::Mat & userData) :
93 UASSERT(image.type() == CV_8UC1);
96 else if(!image.empty())
98 UASSERT(image.type() == CV_8UC1 ||
99 image.type() == CV_8UC3);
103 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
116 const cv::Mat & depth,
120 const cv::Mat & userData) :
128 UASSERT(rgb.type() == CV_8UC1);
131 else if(!rgb.empty())
133 UASSERT(rgb.type() == CV_8UC1 ||
134 rgb.type() == CV_8UC3);
140 UASSERT(depth.type() == CV_8UC1);
143 else if(!depth.empty())
145 UASSERT(depth.type() == CV_32FC1 ||
146 depth.type() == CV_16UC1);
150 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
164 const cv::Mat & depth,
168 const cv::Mat & userData) :
176 UASSERT(rgb.type() == CV_8UC1);
179 else if(!rgb.empty())
181 UASSERT(rgb.type() == CV_8UC1 ||
182 rgb.type() == CV_8UC3);
187 UASSERT(depth.type() == CV_8UC1);
190 else if(!depth.empty())
192 UASSERT(depth.type() == CV_32FC1 ||
193 depth.type() == CV_16UC1);
206 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
219 const cv::Mat & depth,
223 const cv::Mat & userData) :
231 UASSERT(rgb.type() == CV_8UC1);
234 else if(!rgb.empty())
236 UASSERT(rgb.type() == CV_8UC1 ||
237 rgb.type() == CV_8UC3);
242 UASSERT(depth.type() == CV_8UC1);
245 else if(!depth.empty())
247 UASSERT(depth.type() == CV_32FC1 ||
248 depth.type() == CV_16UC1);
252 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
266 const cv::Mat & depth,
270 const cv::Mat & userData) :
278 UASSERT(rgb.type() == CV_8UC1);
281 else if(!rgb.empty())
283 UASSERT(rgb.type() == CV_8UC1 ||
284 rgb.type() == CV_8UC3);
289 UASSERT(depth.type() == CV_8UC1);
292 else if(!depth.empty())
294 UASSERT(depth.type() == CV_32FC1 ||
295 depth.type() == CV_16UC1);
308 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
320 const cv::Mat & left,
321 const cv::Mat & right,
325 const cv::Mat & userData):
333 UASSERT(left.type() == CV_8UC1);
336 else if(!left.empty())
338 UASSERT(left.type() == CV_8UC1 ||
339 left.type() == CV_8UC3 ||
340 left.type() == CV_16UC1);
345 UASSERT(right.type() == CV_8UC1);
348 else if(!right.empty())
350 UASSERT(right.type() == CV_8UC1 ||
351 right.type() == CV_16UC1);
355 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
369 const cv::Mat & left,
370 const cv::Mat & right,
374 const cv::Mat & userData) :
382 UASSERT(left.type() == CV_8UC1);
385 else if(!left.empty())
387 UASSERT(left.type() == CV_8UC1 ||
388 left.type() == CV_8UC3);
393 UASSERT(right.type() == CV_8UC1);
396 else if(!right.empty())
398 UASSERT(right.type() == CV_8UC1);
411 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
440 UWARN(
"Cannot write new user data (%d bytes) over existing user " 441 "data (%d bytes, %d compressed). Set user data of %d to null " 442 "before setting a new one.",
443 int(userDataRaw.total()*userDataRaw.elemSize()),
456 UWARN(
"Cannot write new user data (%d bytes) over existing user " 457 "data (%d bytes, %d compressed). Set user data of %d to null " 458 "before setting a new one.",
459 int(userData.total()*userData.elemSize()),
468 if(!userData.empty())
470 if(userData.type() == CV_8UC1 && userData.rows == 1 && userData.cols > int(3*
sizeof(
int)))
483 const cv::Mat & ground,
484 const cv::Mat & obstacles,
485 const cv::Mat & empty,
487 const cv::Point3f & viewPoint)
489 UDEBUG(
"ground=%d obstacles=%d empty=%d", ground.cols, obstacles.cols, empty.cols);
494 UWARN(
"Occupancy grid cannot be overwritten! id=%d", this->
id());
511 if(ground.type() == CV_32FC2 || ground.type() == CV_32FC3 || ground.type() == CV_32FC(4) || ground.type() == CV_32FC(5) || ground.type() == CV_32FC(6) || ground.type() == CV_32FC(7))
516 else if(ground.type() == CV_8UC1)
518 UASSERT(ground.type() == CV_8UC1);
522 if(!obstacles.empty())
524 if(obstacles.type() == CV_32FC2 || obstacles.type() == CV_32FC3 || obstacles.type() == CV_32FC(4) || obstacles.type() == CV_32FC(5) || obstacles.type() == CV_32FC(6) || obstacles.type() == CV_32FC(7))
529 else if(obstacles.type() == CV_8UC1)
531 UASSERT(obstacles.type() == CV_8UC1);
537 if(empty.type() == CV_32FC2 || empty.type() == CV_32FC3 || empty.type() == CV_32FC(4) || empty.type() == CV_32FC(5) || empty.type() == CV_32FC(6) || empty.type() == CV_32FC(7))
542 else if(empty.type() == CV_8UC1)
544 UASSERT(empty.type() == CV_8UC1);
570 cv::Mat tmpA, tmpB, tmpD, tmpE, tmpF, tmpG;
586 cv::Mat * groundCellsRaw,
587 cv::Mat * obstacleCellsRaw,
588 cv::Mat * emptyCellsRaw)
590 UDEBUG(
"%d data(%d,%d,%d,%d,%d,%d,%d)", this->
id(), imageRaw?1:0, depthRaw?1:0, laserScanRaw?1:0, userDataRaw?1:0, groundCellsRaw?1:0, obstacleCellsRaw?1:0, emptyCellsRaw?1:0);
595 groundCellsRaw == 0 &&
596 obstacleCellsRaw == 0 &&
610 if(imageRaw && !imageRaw->empty() &&
_imageRaw.empty())
638 if(userDataRaw && !userDataRaw->empty() &&
_userDataRaw.empty())
642 if(groundCellsRaw && !groundCellsRaw->empty() &&
_groundCellsRaw.empty())
650 if(emptyCellsRaw && !emptyCellsRaw->empty() &&
_emptyCellsRaw.empty())
661 cv::Mat * groundCellsRaw,
662 cv::Mat * obstacleCellsRaw,
663 cv::Mat * emptyCellsRaw)
const 693 if( (imageRaw && imageRaw->empty()) ||
694 (depthRaw && depthRaw->empty()) ||
695 (laserScanRaw && laserScanRaw->
isEmpty()) ||
696 (userDataRaw && userDataRaw->empty()) ||
697 (groundCellsRaw && groundCellsRaw->empty()) ||
698 (obstacleCellsRaw && obstacleCellsRaw->empty()) ||
699 (emptyCellsRaw && emptyCellsRaw->empty()))
731 ctGroundCells.
start();
736 ctObstacleCells.
start();
741 ctEmptyCells.
start();
747 ctGroundCells.
join();
748 ctObstacleCells.
join();
751 if(imageRaw && imageRaw->empty())
754 if(imageRaw->empty())
758 UWARN(
"Requested raw image data, but the sensor data (%d) doesn't have image.", this->
id());
762 UERROR(
"Requested image data, but failed to uncompress (%d).", this->
id());
766 if(depthRaw && depthRaw->empty())
769 if(depthRaw->empty())
773 UWARN(
"Requested depth/right image data, but the sensor data (%d) doesn't have depth/right image.", this->
id());
777 UERROR(
"Requested depth/right image data, but failed to uncompress (%d).", this->
id());
781 if(laserScanRaw && laserScanRaw->
isEmpty())
789 UWARN(
"Requested laser scan data, but the sensor data (%d) doesn't have laser scan.", this->
id());
793 UERROR(
"Requested laser scan data, but failed to uncompress (%d).", this->
id());
797 if(userDataRaw && userDataRaw->empty())
799 *userDataRaw = ctUserData.getUncompressedData();
801 if(userDataRaw->empty())
805 UWARN(
"Requested user data, but the sensor data (%d) doesn't have user data.", this->
id());
809 UERROR(
"Requested user data, but failed to uncompress (%d).", this->
id());
813 if(groundCellsRaw && groundCellsRaw->empty())
817 if(obstacleCellsRaw && obstacleCellsRaw->empty())
821 if(emptyCellsRaw && emptyCellsRaw->empty())
830 UASSERT_MSG(keypoints3D.empty() || keypoints.size() == keypoints3D.size(),
uFormat(
"keypoints=%d keypoints3D=%d", (
int)keypoints.size(), (int)keypoints3D.size()).c_str());
831 UASSERT_MSG(descriptors.empty() || (int)keypoints.size() == descriptors.rows,
uFormat(
"keypoints=%d descriptors=%d", (
int)keypoints.size(), descriptors.rows).c_str());
867 if(ptInCameraFrame.z > 0.0f)
869 int borderWidth = int(
float(
_cameraModels[i].imageWidth())* 0.2);
871 _cameraModels[i].reproject(ptInCameraFrame.x, ptInCameraFrame.y, ptInCameraFrame.z, u, v);
884 if(ptInCameraFrame.z > 0.0f)
894 UERROR(
"no valid camera model!");
void uncompressDataConst(cv::Mat *imageRaw, cv::Mat *depthOrRightRaw, LaserScan *laserScanRaw=0, cv::Mat *userDataRaw=0, cv::Mat *groundCellsRaw=0, cv::Mat *obstacleCellsRaw=0, cv::Mat *emptyCellsRaw=0) const
void setOccupancyGrid(const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewPoint)
cv::Mat _userDataCompressed
cv::Point3f RTABMAP_EXP transformPoint(const cv::Point3f &pt, const Transform &transform)
const cv::Mat & data() const
std::vector< cv::Point3f > _keypoints3D
LaserScan _laserScanCompressed
bool uIsInBounds(const T &value, const T &low, const T &high)
cv::Mat _obstacleCellsRaw
const cv::Mat & descriptors() const
cv::Mat _groundCellsCompressed
const std::vector< cv::KeyPoint > & keypoints() const
Basic mathematics functions.
Some conversion functions.
const LaserScan & laserScanRaw() const
cv::Mat _emptyCellsCompressed
const cv::Mat & imageRaw() const
void setUserData(const cv::Mat &userData)
void setUserDataRaw(const cv::Mat &userDataRaw)
std::vector< cv::KeyPoint > _keypoints
#define UASSERT(condition)
bool isValidForProjection() const
const CameraModel & left() const
#define UASSERT_MSG(condition, msg_str)
cv::Mat _obstacleCellsCompressed
void reproject(float x, float y, float z, float &u, float &v) const
bool isCompressed() const
long getMemoryUsed() const
Transform localTransform() const
cv::Mat RTABMAP_EXP compressData2(const cv::Mat &data)
const cv::Mat & userDataRaw() const
bool isPointVisibleFromCameras(const cv::Point3f &pt) const
cv::Mat _depthOrRightCompressed
const std::vector< CameraModel > & cameraModels() const
const cv::Mat & getCompressedData() const
StereoCameraModel _stereoCameraModel
ULogger class and convenient macros.
std::vector< CameraModel > _cameraModels
void join(bool killFirst=false)
const Transform & localTransform() const
std::string UTILITE_EXP uFormat(const char *fmt,...)
cv::Mat & getUncompressedData()
void setFeatures(const std::vector< cv::KeyPoint > &keypoints, const std::vector< cv::Point3f > &keypoints3D, const cv::Mat &descriptors)
const std::vector< cv::Point3f > & keypoints3D() const
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)