38 #include <pcl/io/pcd_io.h> 39 #include <pcl/io/ply_io.h> 40 #include <pcl/common/transforms.h> 41 #include <opencv2/imgproc/imgproc.hpp> 42 #include <opencv2/imgproc/types_c.h> 50 cv::Mat
bgrFromCloud(
const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
bool bgrOrder)
52 cv::Mat frameBGR = cv::Mat(cloud.height,cloud.width,CV_8UC3);
54 for(
unsigned int h = 0; h < cloud.height; h++)
56 for(
unsigned int w = 0; w < cloud.width; w++)
60 frameBGR.at<cv::Vec3b>(h,w)[0] = cloud.at(h*cloud.width + w).b;
61 frameBGR.at<cv::Vec3b>(h,w)[1] = cloud.at(h*cloud.width + w).g;
62 frameBGR.at<cv::Vec3b>(h,w)[2] = cloud.at(h*cloud.width + w).r;
66 frameBGR.at<cv::Vec3b>(h,w)[0] = cloud.at(h*cloud.width + w).r;
67 frameBGR.at<cv::Vec3b>(h,w)[1] = cloud.at(h*cloud.width + w).g;
68 frameBGR.at<cv::Vec3b>(h,w)[2] = cloud.at(h*cloud.width + w).b;
77 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
82 cv::Mat frameDepth = cv::Mat(cloud.height,cloud.width,depth16U?CV_16UC1:CV_32FC1);
85 for(
unsigned int h = 0; h < cloud.height; h++)
87 for(
unsigned int w = 0; w < cloud.width; w++)
89 float depth = cloud.at(h*cloud.width + w).z;
93 unsigned short depthMM = 0;
94 if(depth <= (
float)USHRT_MAX)
96 depthMM = (
unsigned short)depth;
98 frameDepth.at<
unsigned short>(h,w) = depthMM;
102 frameDepth.at<
float>(h,w) = depth;
107 uIsFinite(cloud.at(h*cloud.width + w).x) &&
109 w != cloud.width/2 &&
112 fx = cloud.at(h*cloud.width + w).x / ((float(w) - float(cloud.width)/2.0f) * depth);
119 uIsFinite(cloud.at(h*cloud.width + w).y) &&
121 h != cloud.height/2 &&
124 fy = cloud.at(h*cloud.width + w).y / ((float(h) - float(cloud.height)/2.0f) * depth);
138 cv::Mat & frameDepth,
144 frameDepth = cv::Mat(cloud.height,cloud.width,depth16U?CV_16UC1:CV_32FC1);
145 frameBGR = cv::Mat(cloud.height,cloud.width,CV_8UC3);
149 for(
unsigned int h = 0; h < cloud.height; h++)
151 for(
unsigned int w = 0; w < cloud.width; w++)
156 frameBGR.at<cv::Vec3b>(h,w)[0] = cloud.at(h*cloud.width + w).b;
157 frameBGR.at<cv::Vec3b>(h,w)[1] = cloud.at(h*cloud.width + w).g;
158 frameBGR.at<cv::Vec3b>(h,w)[2] = cloud.at(h*cloud.width + w).r;
162 frameBGR.at<cv::Vec3b>(h,w)[0] = cloud.at(h*cloud.width + w).r;
163 frameBGR.at<cv::Vec3b>(h,w)[1] = cloud.at(h*cloud.width + w).g;
164 frameBGR.at<cv::Vec3b>(h,w)[2] = cloud.at(h*cloud.width + w).b;
168 float depth = cloud.at(h*cloud.width + w).z;
172 unsigned short depthMM = 0;
173 if(depth <= (
float)USHRT_MAX)
175 depthMM = (
unsigned short)depth;
177 frameDepth.at<
unsigned short>(h,w) = depthMM;
181 frameDepth.at<
float>(h,w) = depth;
186 uIsFinite(cloud.at(h*cloud.width + w).x) &&
188 w != cloud.width/2 &&
191 fx = 1.0f/(cloud.at(h*cloud.width + w).x / ((float(w) - float(cloud.width)/2.0f) * depth));
198 uIsFinite(cloud.at(h*cloud.width + w).y) &&
200 h != cloud.height/2 &&
203 fy = 1.0f/(cloud.at(h*cloud.width + w).y / ((float(h) - float(cloud.height)/2.0f) * depth));
214 const cv::Mat & depthImage,
219 float depthErrorRatio)
221 UASSERT(depthImage.type() == CV_16UC1 || depthImage.type() == CV_32FC1);
225 float depth =
util2d::getDepth(depthImage, x, y, smoothing, depthErrorRatio);
229 cx = cx > 0.0f ? cx : float(depthImage.cols/2) - 0.5f;
230 cy = cy > 0.0f ? cy : float(depthImage.rows/2) - 0.5f;
233 pt.x = (x - cx) * depth / fx;
234 pt.y = (y - cy) * depth / fy;
239 pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN();
245 const cv::Size & imageSize,
253 cx = cx > 0.0f ? cx : float(imageSize.width/2) - 0.5f;
254 cy = cy > 0.0f ? cy : float(imageSize.height/2) - 0.5f;
257 ray[0] = (x - cx) / fx;
258 ray[1] = (y - cy) / fy;
265 const cv::Mat & imageDepth,
271 std::vector<int> * validIndices)
274 return cloudFromDepth(imageDepth, model, decimation, maxDepth, minDepth, validIndices);
278 const cv::Mat & imageDepthIn,
283 std::vector<int> * validIndices)
285 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZ>);
290 float rgbToDepthFactorX = 1.0f;
291 float rgbToDepthFactorY = 1.0f;
294 UASSERT(!imageDepthIn.empty() && (imageDepthIn.type() == CV_16UC1 || imageDepthIn.type() == CV_32FC1));
296 cv::Mat imageDepth = imageDepthIn;
303 UDEBUG(
"Decimation from model (%d)", decimation);
306 UERROR(
"Decimation is not valid for current image size (model.imageHeight()=%d decimation=%d). The cloud is not created.", model.
imageHeight(), decimation);
311 UERROR(
"Decimation is not valid for current image size (model.imageWidth()=%d decimation=%d). The cloud is not created.", model.
imageWidth(), decimation);
316 decimation = -1*decimation;
319 if(targetSize > imageDepthIn.rows)
321 UDEBUG(
"Depth interpolation factor=%d", targetSize/imageDepthIn.rows);
325 else if(targetSize == imageDepthIn.rows)
331 UASSERT(imageDepthIn.rows % targetSize == 0);
332 decimation = imageDepthIn.rows / targetSize;
337 if(imageDepthIn.rows % decimation != 0)
339 UERROR(
"Decimation is not valid for current image size (imageDepth.rows=%d decimation=%d). The cloud is not created.", imageDepthIn.rows, decimation);
342 if(imageDepthIn.cols % decimation != 0)
344 UERROR(
"Decimation is not valid for current image size (imageDepth.cols=%d decimation=%d). The cloud is not created.", imageDepthIn.cols, decimation);
349 rgbToDepthFactorX = 1.0f/float((model.
imageWidth() / imageDepth.cols));
350 rgbToDepthFactorY = 1.0f/float((model.
imageHeight() / imageDepth.rows));
354 decimation =
abs(decimation);
355 UASSERT_MSG(imageDepth.rows % decimation == 0,
uFormat(
"rows=%d decimation=%d", imageDepth.rows, decimation).c_str());
356 UASSERT_MSG(imageDepth.cols % decimation == 0,
uFormat(
"cols=%d decimation=%d", imageDepth.cols, decimation).c_str());
360 cloud->height = imageDepth.rows/decimation;
361 cloud->width = imageDepth.cols/decimation;
362 cloud->is_dense =
false;
363 cloud->resize(cloud->height * cloud->width);
366 validIndices->resize(cloud->size());
369 float depthFx = model.
fx() * rgbToDepthFactorX;
370 float depthFy = model.
fy() * rgbToDepthFactorY;
371 float depthCx = model.
cx() * rgbToDepthFactorX;
372 float depthCy = model.
cy() * rgbToDepthFactorY;
374 UDEBUG(
"depth=%dx%d fx=%f fy=%f cx=%f cy=%f (depth factors=%f %f) decimation=%d",
375 imageDepth.cols, imageDepth.rows,
376 model.
fx(), model.
fy(), model.
cx(), model.
cy(),
382 for(
int h = 0; h < imageDepth.rows && h/decimation < (int)cloud->height; h+=decimation)
384 for(
int w = 0; w < imageDepth.cols && w/decimation < (int)cloud->width; w+=decimation)
386 pcl::PointXYZ & pt = cloud->at((h/decimation)*cloud->width + (w/decimation));
388 pcl::PointXYZ ptXYZ =
projectDepthTo3D(imageDepth, w, h, depthCx, depthCy, depthFx, depthFy,
false);
389 if(
pcl::isFinite(ptXYZ) && ptXYZ.z>=minDepth && (maxDepth<=0.0f || ptXYZ.z <= maxDepth))
396 validIndices->at(oi++) = (h/decimation)*cloud->width + (w/decimation);
401 pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN();
408 validIndices->resize(oi);
415 const cv::Mat & imageRgb,
416 const cv::Mat & imageDepth,
422 std::vector<int> * validIndices)
425 return cloudFromDepthRGB(imageRgb, imageDepth, model, decimation, maxDepth, minDepth, validIndices);
429 const cv::Mat & imageRgb,
430 const cv::Mat & imageDepthIn,
435 std::vector<int> * validIndices)
437 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
447 UASSERT_MSG(imageRgb.rows % imageDepthIn.rows == 0 && imageRgb.cols % imageDepthIn.cols == 0,
448 uFormat(
"rgb=%dx%d depth=%dx%d", imageRgb.cols, imageRgb.rows, imageDepthIn.cols, imageDepthIn.rows).c_str());
449 UASSERT(!imageDepthIn.empty() && (imageDepthIn.type() == CV_16UC1 || imageDepthIn.type() == CV_32FC1));
452 if(imageRgb.rows % decimation != 0 || imageRgb.cols % decimation != 0)
454 int oldDecimation = decimation;
455 while(decimation <= -1)
457 if(imageRgb.rows % decimation == 0 && imageRgb.cols % decimation == 0)
464 if(imageRgb.rows % oldDecimation != 0 || imageRgb.cols % oldDecimation != 0)
466 UWARN(
"Decimation (%d) is not valid for current image size (rgb=%dx%d). Highest compatible decimation used=%d.", oldDecimation, imageRgb.cols, imageRgb.rows, decimation);
472 if(imageDepthIn.rows % decimation != 0 || imageDepthIn.cols % decimation != 0)
474 int oldDecimation = decimation;
475 while(decimation >= 1)
477 if(imageDepthIn.rows % decimation == 0 && imageDepthIn.cols % decimation == 0)
484 if(imageDepthIn.rows % oldDecimation != 0 || imageDepthIn.cols % oldDecimation != 0)
486 UWARN(
"Decimation (%d) is not valid for current image size (depth=%dx%d). Highest compatible decimation used=%d.", oldDecimation, imageDepthIn.cols, imageDepthIn.rows, decimation);
491 cv::Mat imageDepth = imageDepthIn;
494 UDEBUG(
"Decimation from RGB image (%d)", decimation);
496 decimation = -1*decimation;
498 int targetSize = imageRgb.rows / decimation;
499 if(targetSize > imageDepthIn.rows)
501 UDEBUG(
"Depth interpolation factor=%d", targetSize/imageDepthIn.rows);
505 else if(targetSize == imageDepthIn.rows)
511 UASSERT(imageDepthIn.rows % targetSize == 0);
512 decimation = imageDepthIn.rows / targetSize;
517 if(imageRgb.channels() == 3)
521 else if(imageRgb.channels() == 1)
531 cloud->height = imageDepth.rows/decimation;
532 cloud->width = imageDepth.cols/decimation;
533 cloud->is_dense =
false;
534 cloud->resize(cloud->height * cloud->width);
537 validIndices->resize(cloud->size());
540 float rgbToDepthFactorX = float(imageRgb.cols) / float(imageDepth.cols);
541 float rgbToDepthFactorY = float(imageRgb.rows) / float(imageDepth.rows);
542 float depthFx = model.
fx() / rgbToDepthFactorX;
543 float depthFy = model.
fy() / rgbToDepthFactorY;
544 float depthCx = model.
cx() / rgbToDepthFactorX;
545 float depthCy = model.
cy() / rgbToDepthFactorY;
547 UDEBUG(
"rgb=%dx%d depth=%dx%d fx=%f fy=%f cx=%f cy=%f (depth factors=%f %f) decimation=%d",
548 imageRgb.cols, imageRgb.rows,
549 imageDepth.cols, imageDepth.rows,
550 model.
fx(), model.
fy(), model.
cx(), model.
cy(),
556 for(
int h = 0; h < imageDepth.rows && h/decimation < (int)cloud->height; h+=decimation)
558 for(
int w = 0; w < imageDepth.cols && w/decimation < (int)cloud->width; w+=decimation)
560 pcl::PointXYZRGB & pt = cloud->at((h/decimation)*cloud->width + (w/decimation));
562 int x = int(w*rgbToDepthFactorX);
563 int y = int(h*rgbToDepthFactorY);
564 UASSERT(x >=0 && x<imageRgb.cols && y >=0 && y<imageRgb.rows);
567 const unsigned char * bgr = imageRgb.ptr<
unsigned char>(y,x);
574 unsigned char v = imageRgb.at<
unsigned char>(y,x);
580 pcl::PointXYZ ptXYZ =
projectDepthTo3D(imageDepth, w, h, depthCx, depthCy, depthFx, depthFy,
false);
581 if (
pcl::isFinite(ptXYZ) && ptXYZ.z >= minDepth && (maxDepth <= 0.0f || ptXYZ.z <= maxDepth))
588 validIndices->at(oi) = (h / decimation)*cloud->width + (w / decimation);
594 pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN();
600 validIndices->resize(oi);
604 UWARN(
"Cloud with only NaN values created!");
611 const cv::Mat & imageDisparity,
616 std::vector<int> * validIndices)
618 UASSERT(imageDisparity.type() == CV_32FC1 || imageDisparity.type()==CV_16SC1);
621 if(imageDisparity.rows % decimation != 0 || imageDisparity.cols % decimation != 0)
623 int oldDecimation = decimation;
624 while(decimation >= 1)
626 if(imageDisparity.rows % decimation == 0 && imageDisparity.cols % decimation == 0)
633 if(imageDisparity.rows % oldDecimation != 0 || imageDisparity.cols % oldDecimation != 0)
635 UWARN(
"Decimation (%d) is not valid for current image size (depth=%dx%d). Highest compatible decimation used=%d.", oldDecimation, imageDisparity.cols, imageDisparity.rows, decimation);
639 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZ>);
642 cloud->height = imageDisparity.rows/decimation;
643 cloud->width = imageDisparity.cols/decimation;
644 cloud->is_dense =
false;
645 cloud->resize(cloud->height * cloud->width);
648 validIndices->resize(cloud->size());
652 if(imageDisparity.type()==CV_16SC1)
654 for(
int h = 0; h < imageDisparity.rows && h/decimation < (int)cloud->height; h+=decimation)
656 for(
int w = 0; w < imageDisparity.cols && w/decimation < (int)cloud->width; w+=decimation)
658 float disp = float(imageDisparity.at<
short>(h,w))/16.0f;
660 if(pt.z >= minDepth && (maxDepth <= 0.0f || pt.z <= maxDepth))
662 cloud->at((h/decimation)*cloud->width + (w/decimation)) = pcl::PointXYZ(pt.x, pt.y, pt.z);
665 validIndices->at(oi++) = (h/decimation)*cloud->width + (w/decimation);
670 cloud->at((h/decimation)*cloud->width + (w/decimation)) = pcl::PointXYZ(
671 std::numeric_limits<float>::quiet_NaN(),
672 std::numeric_limits<float>::quiet_NaN(),
673 std::numeric_limits<float>::quiet_NaN());
680 for(
int h = 0; h < imageDisparity.rows && h/decimation < (int)cloud->height; h+=decimation)
682 for(
int w = 0; w < imageDisparity.cols && w/decimation < (int)cloud->width; w+=decimation)
684 float disp = imageDisparity.at<
float>(h,w);
686 if(pt.z > minDepth && (maxDepth <= 0.0f || pt.z <= maxDepth))
688 cloud->at((h/decimation)*cloud->width + (w/decimation)) = pcl::PointXYZ(pt.x, pt.y, pt.z);
691 validIndices->at(oi++) = (h/decimation)*cloud->width + (w/decimation);
696 cloud->at((h/decimation)*cloud->width + (w/decimation)) = pcl::PointXYZ(
697 std::numeric_limits<float>::quiet_NaN(),
698 std::numeric_limits<float>::quiet_NaN(),
699 std::numeric_limits<float>::quiet_NaN());
706 validIndices->resize(oi);
712 const cv::Mat & imageRgb,
713 const cv::Mat & imageDisparity,
718 std::vector<int> * validIndices)
720 UASSERT(!imageRgb.empty() && !imageDisparity.empty());
721 UASSERT(imageRgb.rows == imageDisparity.rows &&
722 imageRgb.cols == imageDisparity.cols &&
723 (imageDisparity.type() == CV_32FC1 || imageDisparity.type()==CV_16SC1));
724 UASSERT(imageRgb.channels() == 3 || imageRgb.channels() == 1);
727 if(imageDisparity.rows % decimation != 0 || imageDisparity.cols % decimation != 0)
729 int oldDecimation = decimation;
730 while(decimation >= 1)
732 if(imageDisparity.rows % decimation == 0 && imageDisparity.cols % decimation == 0)
739 if(imageDisparity.rows % oldDecimation != 0 || imageDisparity.cols % oldDecimation != 0)
741 UWARN(
"Decimation (%d) is not valid for current image size (depth=%dx%d). Highest compatible decimation used=%d.", oldDecimation, imageDisparity.cols, imageDisparity.rows, decimation);
745 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
748 if(imageRgb.channels() == 3)
758 cloud->height = imageRgb.rows/decimation;
759 cloud->width = imageRgb.cols/decimation;
760 cloud->is_dense =
false;
761 cloud->resize(cloud->height * cloud->width);
764 validIndices->resize(cloud->size());
768 for(
int h = 0; h < imageRgb.rows && h/decimation < (int)cloud->height; h+=decimation)
770 for(
int w = 0; w < imageRgb.cols && w/decimation < (int)cloud->width; w+=decimation)
772 pcl::PointXYZRGB & pt = cloud->at((h/decimation)*cloud->width + (w/decimation));
775 pt.b = imageRgb.at<cv::Vec3b>(h,w)[0];
776 pt.g = imageRgb.at<cv::Vec3b>(h,w)[1];
777 pt.r = imageRgb.at<cv::Vec3b>(h,w)[2];
781 unsigned char v = imageRgb.at<
unsigned char>(h,w);
787 float disp = imageDisparity.type()==CV_16SC1?float(imageDisparity.at<
short>(h,w))/16.0f:imageDisparity.at<
float>(h,w);
789 if(
util3d::isFinite(ptXYZ) && ptXYZ.z >= minDepth && (maxDepth<=0.0f || ptXYZ.z <= maxDepth))
796 validIndices->at(oi++) = (h/decimation)*cloud->width + (w/decimation);
801 pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN();
807 validIndices->resize(oi);
813 const cv::Mat & imageLeft,
814 const cv::Mat & imageRight,
819 std::vector<int> * validIndices,
822 UASSERT(!imageLeft.empty() && !imageRight.empty());
823 UASSERT(imageRight.type() == CV_8UC1);
824 UASSERT(imageLeft.channels() == 3 || imageLeft.channels() == 1);
825 UASSERT(imageLeft.rows == imageRight.rows &&
826 imageLeft.cols == imageRight.cols);
829 cv::Mat leftColor = imageLeft;
830 cv::Mat rightMono = imageRight;
833 if(leftColor.channels() == 3)
835 cv::cvtColor(leftColor, leftMono, CV_BGR2GRAY);
839 leftMono = leftColor;
857 std::vector<int> * validIndices,
859 const std::vector<float> & roiRatios)
866 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZ>);
873 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
877 cv::Mat depth = cv::Mat(sensorData.
depthRaw(), cv::Rect(subImageWidth*i, 0, subImageWidth, sensorData.
depthRaw().rows));
879 if( roiRatios.size() == 4 &&
880 (roiRatios[0] > 0.0f ||
881 roiRatios[1] > 0.0f ||
882 roiRatios[2] > 0.0f ||
883 roiRatios[3] > 0.0f))
891 if( roiDepth.width%decimation==0 &&
892 roiDepth.height%decimation==0 &&
893 (roiRgb.width != 0 ||
894 (roiRgb.width%decimation==0 &&
895 roiRgb.height%decimation==0)))
897 depth = cv::Mat(depth, roiDepth);
904 model = model.
roi(roiDepth);
909 UERROR(
"Cannot apply ROI ratios [%f,%f,%f,%f] because resulting " 910 "dimension (depth=%dx%d rgb=%dx%d) cannot be divided exactly " 911 "by decimation parameter (%d). Ignoring ROI ratios...",
952 UERROR(
"Camera model %d is invalid", i);
956 if(cloud->is_dense && validIndices)
959 validIndices->resize(cloud->size());
960 for(
unsigned int i=0; i<cloud->size(); ++i)
962 validIndices->at(i) = i;
972 if(sensorData.
imageRaw().channels() == 3)
974 cv::cvtColor(sensorData.
imageRaw(), leftMono, CV_BGR2GRAY);
981 cv::Mat right(sensorData.
rightRaw());
983 if( roiRatios.size() == 4 &&
984 ((roiRatios[0] > 0.0f && roiRatios[0] <= 1.0f) ||
985 (roiRatios[1] > 0.0
f && roiRatios[1] <= 1.0
f) ||
986 (roiRatios[2] > 0.0f && roiRatios[2] <= 1.0f) ||
987 (roiRatios[3] > 0.0
f && roiRatios[3] <= 1.0
f)))
990 if( roi.width%decimation==0 &&
991 roi.height%decimation==0)
993 leftMono = cv::Mat(leftMono, roi);
994 right = cv::Mat(right, roi);
999 UERROR(
"Cannot apply ROI ratios [%f,%f,%f,%f] because resulting " 1000 "dimension (left=%dx%d) cannot be divided exactly " 1001 "by decimation parameter (%d). Ignoring ROI ratios...",
1036 std::vector<int> * validIndices,
1038 const std::vector<float> & roiRatios)
1045 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
1058 for(
unsigned int i=0; i<sensorData.
cameraModels().size(); ++i)
1060 if(sensorData.
cameraModels()[i].isValidForProjection())
1062 cv::Mat rgb(sensorData.
imageRaw(), cv::Rect(subRGBWidth*i, 0, subRGBWidth, sensorData.
imageRaw().rows));
1063 cv::Mat depth(sensorData.
depthRaw(), cv::Rect(subDepthWidth*i, 0, subDepthWidth, sensorData.
depthRaw().rows));
1065 if( roiRatios.size() == 4 &&
1066 ((roiRatios[0] > 0.0f && roiRatios[0] <= 1.0f) ||
1067 (roiRatios[1] > 0.0
f && roiRatios[1] <= 1.0
f) ||
1068 (roiRatios[2] > 0.0f && roiRatios[2] <= 1.0f) ||
1069 (roiRatios[3] > 0.0
f && roiRatios[3] <= 1.0
f)))
1073 if( roiDepth.width%decimation==0 &&
1074 roiDepth.height%decimation==0 &&
1075 roiRgb.width%decimation==0 &&
1076 roiRgb.height%decimation==0)
1078 depth = cv::Mat(depth, roiDepth);
1079 rgb = cv::Mat(rgb, roiRgb);
1080 model = model.
roi(roiRgb);
1084 UERROR(
"Cannot apply ROI ratios [%f,%f,%f,%f] because resulting " 1085 "dimension (depth=%dx%d rgb=%dx%d) cannot be divided exactly " 1086 "by decimation parameter (%d). Ignoring ROI ratios...",
1128 UERROR(
"Camera model %d is invalid", i);
1132 if(cloud->is_dense && validIndices)
1135 validIndices->resize(cloud->size());
1136 for(
unsigned int i=0; i<cloud->size(); ++i)
1138 validIndices->at(i) = i;
1147 cv::Mat left(sensorData.
imageRaw());
1148 cv::Mat right(sensorData.
rightRaw());
1150 if( roiRatios.size() == 4 &&
1151 ((roiRatios[0] > 0.0f && roiRatios[0] <= 1.0f) ||
1152 (roiRatios[1] > 0.0
f && roiRatios[1] <= 1.0
f) ||
1153 (roiRatios[2] > 0.0f && roiRatios[2] <= 1.0f) ||
1154 (roiRatios[3] > 0.0
f && roiRatios[3] <= 1.0
f)))
1157 if( roi.width%decimation==0 &&
1158 roi.height%decimation==0)
1160 left = cv::Mat(left, roi);
1161 right = cv::Mat(right, roi);
1166 UERROR(
"Cannot apply ROI ratios [%f,%f,%f,%f] because resulting " 1167 "dimension (left=%dx%d) cannot be divided exactly " 1168 "by decimation parameter (%d). Ignoring ROI ratios...",
1198 const cv::Mat & depthImage,
1207 UASSERT(depthImage.type() == CV_16UC1 || depthImage.type() == CV_32FC1);
1210 pcl::PointCloud<pcl::PointXYZ> scan;
1211 int middle = depthImage.rows/2;
1214 scan.resize(depthImage.cols);
1216 for(
int i=depthImage.cols-1; i>=0; --i)
1219 if(
pcl::isFinite(pt) && pt.z >= minDepth && (maxDepth == 0 || pt.z < maxDepth))
1234 const cv::Mat & depthImages,
1235 const std::vector<CameraModel> & cameraModels,
1239 pcl::PointCloud<pcl::PointXYZ> scan;
1240 UASSERT(
int((depthImages.cols/cameraModels.size())*cameraModels.size()) == depthImages.cols);
1241 int subImageWidth = depthImages.cols/cameraModels.size();
1242 for(
int i=(
int)cameraModels.size()-1; i>=0; --i)
1244 if(cameraModels[i].isValidForProjection())
1246 cv::Mat depth = cv::Mat(depthImages, cv::Rect(subImageWidth*i, 0, subImageWidth, depthImages.rows));
1250 cameraModels[i].fx(),
1251 cameraModels[i].fy(),
1252 cameraModels[i].cx(),
1253 cameraModels[i].cy(),
1256 cameraModels[i].localTransform());
1260 UERROR(
"Camera model %d is invalid", i);
1268 if(cloud.data.empty())
1273 int fieldStates[8] = {0};
1275 for(
unsigned int i=0; i<cloud.fields.size(); ++i)
1277 if(cloud.fields[i].name.compare(
"x") == 0)
1280 fieldOffsets[0] = cloud.fields[i].offset;
1282 else if(cloud.fields[i].name.compare(
"y") == 0)
1285 fieldOffsets[1] = cloud.fields[i].offset;
1287 else if(cloud.fields[i].name.compare(
"z") == 0)
1290 fieldOffsets[2] = cloud.fields[i].offset;
1292 else if(cloud.fields[i].name.compare(
"normal_x") == 0)
1295 fieldOffsets[3] = cloud.fields[i].offset;
1297 else if(cloud.fields[i].name.compare(
"normal_y") == 0)
1300 fieldOffsets[4] = cloud.fields[i].offset;
1302 else if(cloud.fields[i].name.compare(
"normal_z") == 0)
1305 fieldOffsets[5] = cloud.fields[i].offset;
1307 else if(cloud.fields[i].name.compare(
"rgb") == 0 || cloud.fields[i].name.compare(
"rgba") == 0)
1310 fieldOffsets[6] = cloud.fields[i].offset;
1312 else if(cloud.fields[i].name.compare(
"intensity") == 0)
1315 fieldOffsets[7] = cloud.fields[i].offset;
1319 UDEBUG(
"Ignoring \"%s\" field", cloud.fields[i].name.c_str());
1322 if(fieldStates[0]==0 || fieldStates[1]==0)
1325 UERROR(
"Cloud has not corresponding fields to laser scan!");
1329 bool hasNormals = fieldStates[3] || fieldStates[4] || fieldStates[5];
1330 bool hasIntensity = fieldStates[7];
1331 bool hasRGB = !hasIntensity&&fieldStates[6];
1332 bool is3D = fieldStates[0] && fieldStates[1] && fieldStates[2];
1337 if(hasNormals && hasIntensity)
1341 else if(hasNormals && hasRGB)
1345 else if(!hasNormals && hasIntensity)
1349 else if(!hasNormals && hasRGB)
1360 if(hasNormals && hasIntensity)
1364 else if(!hasNormals && hasIntensity)
1374 UASSERT(cloud.data.size()/cloud.point_step == cloud.height*cloud.width);
1375 cv::Mat laserScan = cv::Mat(1, (
int)cloud.data.size()/cloud.point_step, CV_32FC(
LaserScan::channels(format)));
1380 const uint8_t* row_data = &cloud.data[
row * cloud.row_step];
1381 for (
uint32_t col = 0; col < cloud.width; ++col)
1383 const uint8_t* msg_data = row_data + col * cloud.point_step;
1385 float * ptr = laserScan.ptr<
float>(0, oi);
1388 if(laserScan.channels() == 2)
1390 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1391 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1394 else if(laserScan.channels() == 3)
1396 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1397 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1400 ptr[2] = *(
float*)(msg_data + fieldOffsets[7]);
1404 ptr[2] = *(
float*)(msg_data + fieldOffsets[2]);
1408 else if(laserScan.channels() == 4)
1410 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1411 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1412 ptr[2] = *(
float*)(msg_data + fieldOffsets[2]);
1415 ptr[3] = *(
float*)(msg_data + fieldOffsets[7]);
1422 int * ptrInt = (
int*)ptr;
1423 ptrInt[3] = int(b) | (int(g) << 8) | (
int(r) << 16);
1427 else if(laserScan.channels() == 5)
1429 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1430 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1431 ptr[2] = *(
float*)(msg_data + fieldOffsets[3]);
1432 ptr[3] = *(
float*)(msg_data + fieldOffsets[4]);
1433 ptr[4] = *(
float*)(msg_data + fieldOffsets[5]);
1436 else if(laserScan.channels() == 6)
1438 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1439 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1442 ptr[2] = *(
float*)(msg_data + fieldOffsets[7]);
1446 ptr[2] = *(
float*)(msg_data + fieldOffsets[2]);
1448 ptr[3] = *(
float*)(msg_data + fieldOffsets[3]);
1449 ptr[4] = *(
float*)(msg_data + fieldOffsets[4]);
1450 ptr[5] = *(
float*)(msg_data + fieldOffsets[5]);
1453 else if(laserScan.channels() == 7)
1455 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1456 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1457 ptr[2] = *(
float*)(msg_data + fieldOffsets[2]);
1460 ptr[3] = *(
float*)(msg_data + fieldOffsets[7]);
1467 int * ptrInt = (
int*)ptr;
1468 ptrInt[3] = int(b) | (int(g) << 8) | (
int(r) << 16);
1470 ptr[4] = *(
float*)(msg_data + fieldOffsets[3]);
1471 ptr[5] = *(
float*)(msg_data + fieldOffsets[4]);
1472 ptr[6] = *(
float*)(msg_data + fieldOffsets[5]);
1477 UFATAL(
"Cannot handle as many channels (%d)!", laserScan.channels());
1480 if(!filterNaNs || valid)
1501 Eigen::Affine3f transform3f = transform.
toEigen3f();
1505 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC3);
1506 for(
unsigned int i=0; i<indices->size(); ++i)
1508 int index = indices->at(i);
1511 float * ptr = laserScan.ptr<
float>(0, oi++);
1521 ptr[0] = cloud.at(index).x;
1522 ptr[1] = cloud.at(index).y;
1523 ptr[2] = cloud.at(index).z;
1530 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC3);
1531 for(
unsigned int i=0; i<cloud.size(); ++i)
1535 float * ptr = laserScan.ptr<
float>(0, oi++);
1545 ptr[0] = cloud.at(i).x;
1546 ptr[1] = cloud.at(i).y;
1547 ptr[2] = cloud.at(i).z;
1570 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC(6));
1571 for(
unsigned int i=0; i<indices->size(); ++i)
1573 int index = indices->at(i);
1579 float * ptr = laserScan.ptr<
float>(0, oi++);
1586 ptr[3] = pt.normal_x;
1587 ptr[4] = pt.normal_y;
1588 ptr[5] = pt.normal_z;
1592 ptr[0] = cloud.at(index).x;
1593 ptr[1] = cloud.at(index).y;
1594 ptr[2] = cloud.at(index).z;
1595 ptr[3] = cloud.at(index).normal_x;
1596 ptr[4] = cloud.at(index).normal_y;
1597 ptr[5] = cloud.at(index).normal_z;
1604 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(6));
1605 for(
unsigned int i=0; i<cloud.size(); ++i)
1612 float * ptr = laserScan.ptr<
float>(0, oi++);
1619 ptr[3] = pt.normal_x;
1620 ptr[4] = pt.normal_y;
1621 ptr[5] = pt.normal_z;
1625 ptr[0] = cloud.at(i).x;
1626 ptr[1] = cloud.at(i).y;
1627 ptr[2] = cloud.at(i).z;
1628 ptr[3] = cloud.at(i).normal_x;
1629 ptr[4] = cloud.at(i).normal_y;
1630 ptr[5] = cloud.at(i).normal_z;
1644 UASSERT(cloud.size() == normals.size());
1645 cv::Mat laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(6));
1648 for(
unsigned int i=0; i<cloud.size(); ++i)
1652 float * ptr = laserScan.ptr<
float>(0, oi++);
1655 pcl::PointNormal pt;
1656 pt.x = cloud.at(i).x;
1657 pt.y = cloud.at(i).y;
1658 pt.z = cloud.at(i).z;
1659 pt.normal_x = normals.at(i).normal_x;
1660 pt.normal_y = normals.at(i).normal_y;
1661 pt.normal_z = normals.at(i).normal_z;
1666 ptr[3] = pt.normal_x;
1667 ptr[4] = pt.normal_y;
1668 ptr[5] = pt.normal_z;
1672 ptr[0] = cloud.at(i).x;
1673 ptr[1] = cloud.at(i).y;
1674 ptr[2] = cloud.at(i).z;
1675 ptr[3] = normals.at(i).normal_x;
1676 ptr[4] = normals.at(i).normal_y;
1677 ptr[5] = normals.at(i).normal_z;
1697 Eigen::Affine3f transform3f = transform.
toEigen3f();
1701 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC(4));
1702 for(
unsigned int i=0; i<indices->size(); ++i)
1704 int index = indices->at(i);
1707 float * ptr = laserScan.ptr<
float>(0, oi++);
1717 ptr[0] = cloud.at(index).x;
1718 ptr[1] = cloud.at(index).y;
1719 ptr[2] = cloud.at(index).z;
1721 int * ptrInt = (
int*)ptr;
1722 ptrInt[3] = int(cloud.at(index).b) | (
int(cloud.at(index).g) << 8) | (int(cloud.at(index).r) << 16);
1728 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(4));
1729 for(
unsigned int i=0; i<cloud.size(); ++i)
1733 float * ptr = laserScan.ptr<
float>(0, oi++);
1743 ptr[0] = cloud.at(i).x;
1744 ptr[1] = cloud.at(i).y;
1745 ptr[2] = cloud.at(i).z;
1747 int * ptrInt = (
int*)ptr;
1748 ptrInt[3] = int(cloud.at(i).b) | (
int(cloud.at(i).g) << 8) | (int(cloud.at(i).r) << 16);
1768 Eigen::Affine3f transform3f = transform.
toEigen3f();
1772 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC(4));
1773 for(
unsigned int i=0; i<indices->size(); ++i)
1775 int index = indices->at(i);
1778 float * ptr = laserScan.ptr<
float>(0, oi++);
1788 ptr[0] = cloud.at(index).x;
1789 ptr[1] = cloud.at(index).y;
1790 ptr[2] = cloud.at(index).z;
1792 ptr[3] = cloud.at(index).intensity;
1798 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(4));
1799 for(
unsigned int i=0; i<cloud.size(); ++i)
1803 float * ptr = laserScan.ptr<
float>(0, oi++);
1813 ptr[0] = cloud.at(i).x;
1814 ptr[1] = cloud.at(i).y;
1815 ptr[2] = cloud.at(i).z;
1817 ptr[3] = cloud.at(i).intensity;
1830 UASSERT(cloud.size() == normals.size());
1831 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(7));
1834 for(
unsigned int i=0; i<cloud.size(); ++i)
1838 float * ptr = laserScan.ptr<
float>(0, oi++);
1841 pcl::PointXYZRGBNormal pt;
1842 pt.x = cloud.at(i).x;
1843 pt.y = cloud.at(i).y;
1844 pt.z = cloud.at(i).z;
1845 pt.normal_x = normals.at(i).normal_x;
1846 pt.normal_y = normals.at(i).normal_y;
1847 pt.normal_z = normals.at(i).normal_z;
1852 ptr[4] = pt.normal_x;
1853 ptr[5] = pt.normal_y;
1854 ptr[6] = pt.normal_z;
1858 ptr[0] = cloud.at(i).x;
1859 ptr[1] = cloud.at(i).y;
1860 ptr[2] = cloud.at(i).z;
1861 ptr[4] = normals.at(i).normal_x;
1862 ptr[5] = normals.at(i).normal_y;
1863 ptr[6] = normals.at(i).normal_z;
1865 int * ptrInt = (
int*)ptr;
1866 ptrInt[3] = int(cloud.at(i).b) | (
int(cloud.at(i).g) << 8) | (int(cloud.at(i).r) << 16);
1887 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC(7));
1888 for(
unsigned int i=0; i<indices->size(); ++i)
1890 int index = indices->at(i);
1896 float * ptr = laserScan.ptr<
float>(0, oi++);
1903 ptr[4] = pt.normal_x;
1904 ptr[5] = pt.normal_y;
1905 ptr[6] = pt.normal_z;
1909 ptr[0] = cloud.at(index).x;
1910 ptr[1] = cloud.at(index).y;
1911 ptr[2] = cloud.at(index).z;
1912 ptr[4] = cloud.at(index).normal_x;
1913 ptr[5] = cloud.at(index).normal_y;
1914 ptr[6] = cloud.at(index).normal_z;
1916 int * ptrInt = (
int*)ptr;
1917 ptrInt[3] = int(cloud.at(index).b) | (
int(cloud.at(index).g) << 8) | (int(cloud.at(index).r) << 16);
1923 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(7));
1924 for(
unsigned int i=0; i<cloud.size(); ++i)
1931 float * ptr = laserScan.ptr<
float>(0, oi++);
1938 ptr[4] = pt.normal_x;
1939 ptr[5] = pt.normal_y;
1940 ptr[6] = pt.normal_z;
1944 ptr[0] = cloud.at(i).x;
1945 ptr[1] = cloud.at(i).y;
1946 ptr[2] = cloud.at(i).z;
1947 ptr[4] = cloud.at(i).normal_x;
1948 ptr[5] = cloud.at(i).normal_y;
1949 ptr[6] = cloud.at(i).normal_z;
1951 int * ptrInt = (
int*)ptr;
1952 ptrInt[3] = int(cloud.at(i).b) | (
int(cloud.at(i).g) << 8) | (int(cloud.at(i).r) << 16);
1965 UASSERT(cloud.size() == normals.size());
1966 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(7));
1969 for(
unsigned int i=0; i<cloud.size(); ++i)
1973 float * ptr = laserScan.ptr<
float>(0, oi++);
1976 pcl::PointXYZINormal pt;
1977 pt.x = cloud.at(i).x;
1978 pt.y = cloud.at(i).y;
1979 pt.z = cloud.at(i).z;
1980 pt.normal_x = normals.at(i).normal_x;
1981 pt.normal_y = normals.at(i).normal_y;
1982 pt.normal_z = normals.at(i).normal_z;
1987 ptr[4] = pt.normal_x;
1988 ptr[5] = pt.normal_y;
1989 ptr[6] = pt.normal_z;
1993 ptr[0] = cloud.at(i).x;
1994 ptr[1] = cloud.at(i).y;
1995 ptr[2] = cloud.at(i).z;
1996 ptr[4] = normals.at(i).normal_x;
1997 ptr[5] = normals.at(i).normal_y;
1998 ptr[6] = normals.at(i).normal_z;
2000 ptr[3] = cloud.at(i).intensity;
2011 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(7));
2014 for(
unsigned int i=0; i<cloud.size(); ++i)
2021 float * ptr = laserScan.ptr<
float>(0, oi++);
2028 ptr[4] = pt.normal_x;
2029 ptr[5] = pt.normal_y;
2030 ptr[6] = pt.normal_z;
2034 ptr[0] = cloud.at(i).x;
2035 ptr[1] = cloud.at(i).y;
2036 ptr[2] = cloud.at(i).z;
2037 ptr[4] = cloud.at(i).normal_x;
2038 ptr[5] = cloud.at(i).normal_y;
2039 ptr[6] = cloud.at(i).normal_z;
2041 ptr[3] = cloud.at(i).intensity;
2053 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC2);
2054 bool nullTransform = transform.
isNull();
2055 Eigen::Affine3f transform3f = transform.
toEigen3f();
2057 for(
unsigned int i=0; i<cloud.size(); ++i)
2061 float * ptr = laserScan.ptr<
float>(0, oi++);
2070 ptr[0] = cloud.at(i).x;
2071 ptr[1] = cloud.at(i).y;
2085 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC3);
2086 bool nullTransform = transform.
isNull();
2087 Eigen::Affine3f transform3f = transform.
toEigen3f();
2089 for(
unsigned int i=0; i<cloud.size(); ++i)
2093 float * ptr = laserScan.ptr<
float>(0, oi++);
2099 ptr[2] = pt.intensity;
2103 ptr[0] = cloud.at(i).x;
2104 ptr[1] = cloud.at(i).y;
2105 ptr[2] = cloud.at(i).intensity;
2119 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(5));
2120 bool nullTransform = transform.
isNull();
2122 for(
unsigned int i=0; i<cloud.size(); ++i)
2129 float * ptr = laserScan.ptr<
float>(0, oi++);
2135 ptr[2] = pt.normal_x;
2136 ptr[3] = pt.normal_y;
2137 ptr[4] = pt.normal_z;
2141 const pcl::PointNormal & pt = cloud.at(i);
2144 ptr[2] = pt.normal_x;
2145 ptr[3] = pt.normal_y;
2146 ptr[4] = pt.normal_z;
2159 UASSERT(cloud.size() == normals.size());
2160 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(5));
2163 for(
unsigned int i=0; i<cloud.size(); ++i)
2167 float * ptr = laserScan.ptr<
float>(0, oi++);
2170 pcl::PointNormal pt;
2171 pt.x = cloud.at(i).x;
2172 pt.y = cloud.at(i).y;
2173 pt.z = cloud.at(i).z;
2174 pt.normal_x = normals.at(i).normal_x;
2175 pt.normal_y = normals.at(i).normal_y;
2176 pt.normal_z = normals.at(i).normal_z;
2180 ptr[2] = pt.normal_x;
2181 ptr[3] = pt.normal_y;
2182 ptr[4] = pt.normal_z;
2186 ptr[0] = cloud.at(i).x;
2187 ptr[1] = cloud.at(i).y;
2188 ptr[2] = normals.at(i).normal_x;
2189 ptr[3] = normals.at(i).normal_y;
2190 ptr[4] = normals.at(i).normal_z;
2203 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(6));
2204 bool nullTransform = transform.
isNull();
2206 for(
unsigned int i=0; i<cloud.size(); ++i)
2213 float * ptr = laserScan.ptr<
float>(0, oi++);
2219 ptr[2] = pt.intensity;
2220 ptr[3] = pt.normal_x;
2221 ptr[4] = pt.normal_y;
2222 ptr[5] = pt.normal_z;
2226 const pcl::PointXYZINormal & pt = cloud.at(i);
2229 ptr[2] = pt.intensity;
2230 ptr[3] = pt.normal_x;
2231 ptr[4] = pt.normal_y;
2232 ptr[5] = pt.normal_z;
2245 UASSERT(cloud.size() == normals.size());
2246 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(6));
2249 for(
unsigned int i=0; i<cloud.size(); ++i)
2253 float * ptr = laserScan.ptr<
float>(0, oi++);
2256 pcl::PointXYZINormal pt;
2257 pt.x = cloud.at(i).x;
2258 pt.y = cloud.at(i).y;
2259 pt.z = cloud.at(i).z;
2260 pt.normal_x = normals.at(i).normal_x;
2261 pt.normal_y = normals.at(i).normal_y;
2262 pt.normal_z = normals.at(i).normal_z;
2266 ptr[2] = pt.intensity;
2267 ptr[3] = pt.normal_x;
2268 ptr[4] = pt.normal_y;
2269 ptr[5] = pt.normal_z;
2273 ptr[0] = cloud.at(i).x;
2274 ptr[1] = cloud.at(i).y;
2275 ptr[2] = cloud.at(i).intensity;
2276 ptr[3] = normals.at(i).normal_x;
2277 ptr[4] = normals.at(i).normal_y;
2278 ptr[5] = normals.at(i).normal_z;
2291 pcl::PCLPointCloud2::Ptr cloud(
new pcl::PCLPointCloud2);
2323 UERROR(
"Unknown conversion from LaserScan format %d to PointCloud2.", laserScan.
format());
2330 pcl::PointCloud<pcl::PointXYZ>::Ptr output(
new pcl::PointCloud<pcl::PointXYZ>);
2331 output->resize(laserScan.
size());
2332 output->is_dense =
true;
2333 bool nullTransform = transform.
isNull();
2334 Eigen::Affine3f transform3f = transform.
toEigen3f();
2335 for(
int i=0; i<laserScan.
size(); ++i)
2348 pcl::PointCloud<pcl::PointNormal>::Ptr output(
new pcl::PointCloud<pcl::PointNormal>);
2349 output->resize(laserScan.
size());
2350 output->is_dense =
true;
2351 bool nullTransform = transform.
isNull();
2352 for(
int i=0; i<laserScan.
size(); ++i)
2365 pcl::PointCloud<pcl::PointXYZRGB>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGB>);
2366 output->resize(laserScan.
size());
2367 output->is_dense =
true;
2369 Eigen::Affine3f transform3f = transform.
toEigen3f();
2370 for(
int i=0; i<laserScan.
size(); ++i)
2383 pcl::PointCloud<pcl::PointXYZI>::Ptr output(
new pcl::PointCloud<pcl::PointXYZI>);
2384 output->resize(laserScan.
size());
2385 output->is_dense =
true;
2387 Eigen::Affine3f transform3f = transform.
toEigen3f();
2388 for(
int i=0; i<laserScan.
size(); ++i)
2401 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
2402 output->resize(laserScan.
size());
2403 output->is_dense =
true;
2405 for(
int i=0; i<laserScan.
size(); ++i)
2418 pcl::PointCloud<pcl::PointXYZINormal>::Ptr output(
new pcl::PointCloud<pcl::PointXYZINormal>);
2419 output->resize(laserScan.
size());
2420 output->is_dense =
true;
2422 for(
int i=0; i<laserScan.
size(); ++i)
2436 pcl::PointXYZ output;
2437 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2440 if(!laserScan.
is2d())
2450 pcl::PointNormal output;
2451 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2454 if(!laserScan.
is2d())
2461 output.normal_x = ptr[offset];
2462 output.normal_y = ptr[offset+1];
2463 output.normal_z = ptr[offset+2];
2471 pcl::PointXYZRGB output;
2472 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2475 if(!laserScan.
is2d())
2482 int * ptrInt = (
int*)ptr;
2484 output.b = (
unsigned char)(ptrInt[indexRGB] & 0xFF);
2485 output.g = (
unsigned char)((ptrInt[indexRGB] >> 8) & 0xFF);
2486 output.r = (
unsigned char)((ptrInt[indexRGB] >> 16) & 0xFF);
2500 pcl::PointXYZI output;
2501 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2504 if(!laserScan.
is2d())
2512 output.intensity = ptr[offset];
2516 output.intensity = intensity;
2525 pcl::PointXYZRGBNormal output;
2526 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2529 if(!laserScan.
is2d())
2536 int * ptrInt = (
int*)ptr;
2538 output.b = (
unsigned char)(ptrInt[indexRGB] & 0xFF);
2539 output.g = (
unsigned char)((ptrInt[indexRGB] >> 8) & 0xFF);
2540 output.r = (
unsigned char)((ptrInt[indexRGB] >> 16) & 0xFF);
2552 output.normal_x = ptr[offset];
2553 output.normal_y = ptr[offset+1];
2554 output.normal_z = ptr[offset+2];
2563 pcl::PointXYZINormal output;
2564 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2567 if(!laserScan.
is2d())
2575 output.intensity = ptr[offset];
2579 output.intensity = intensity;
2585 output.normal_x = ptr[offset];
2586 output.normal_y = ptr[offset+1];
2587 output.normal_z = ptr[offset+2];
2596 UASSERT(laserScan.type() == CV_32FC2 || laserScan.type() == CV_32FC3 || laserScan.type() == CV_32FC(4) || laserScan.type() == CV_32FC(5) || laserScan.type() == CV_32FC(6) || laserScan.type() == CV_32FC(7));
2598 const float * ptr = laserScan.ptr<
float>(0, 0);
2599 min.x = max.x = ptr[0];
2600 min.y = max.y = ptr[1];
2601 bool is3d = laserScan.channels() >= 3 && laserScan.channels() != 5;
2602 min.z = max.z = is3d?ptr[2]:0.0f;
2603 for(
int i=1; i<laserScan.cols; ++i)
2605 ptr = laserScan.ptr<
float>(0, i);
2607 if(ptr[0] < min.x) min.x = ptr[0];
2608 else if(ptr[0] > max.x) max.x = ptr[0];
2610 if(ptr[1] < min.y) min.y = ptr[1];
2611 else if(ptr[1] > max.y) max.y = ptr[1];
2615 if(ptr[2] < min.z) min.z = ptr[2];
2616 else if(ptr[2] > max.z) max.z = ptr[2];
2622 cv::Point3f minCV, maxCV;
2634 const cv::Point2f & pt,
2638 if(disparity > 0.0
f && model.
baseline() > 0.0f && model.
left().
fx() > 0.0f)
2646 float W = model.
baseline()/(disparity + c);
2647 return cv::Point3f((pt.x - model.
left().
cx())*W, (pt.y - model.
left().
cy())*W, model.
left().
fx()*W);
2649 float bad_point = std::numeric_limits<float>::quiet_NaN ();
2650 return cv::Point3f(bad_point, bad_point, bad_point);
2654 const cv::Point2f & pt,
2655 const cv::Mat & disparity,
2658 UASSERT(!disparity.empty() && (disparity.type() == CV_32FC1 || disparity.type() == CV_16SC1));
2659 int u = int(pt.x+0.5f);
2660 int v = int(pt.y+0.5f);
2661 float bad_point = std::numeric_limits<float>::quiet_NaN ();
2665 float d = disparity.type() == CV_16SC1?float(disparity.at<
short>(v,u))/16.0f:disparity.at<
float>(v,u);
2668 return cv::Point3f(bad_point, bad_point, bad_point);
2673 const cv::Size & imageSize,
2674 const cv::Mat & cameraMatrixK,
2675 const cv::Mat & laserScan,
2680 UASSERT(laserScan.type() == CV_32FC2 || laserScan.type() == CV_32FC3 || laserScan.type() == CV_32FC(4) || laserScan.type() == CV_32FC(5) || laserScan.type() == CV_32FC(6) || laserScan.type() == CV_32FC(7));
2681 UASSERT(cameraMatrixK.type() == CV_64FC1 && cameraMatrixK.cols == 3 && cameraMatrixK.cols == 3);
2683 float fx = cameraMatrixK.at<
double>(0,0);
2684 float fy = cameraMatrixK.at<
double>(1,1);
2685 float cx = cameraMatrixK.at<
double>(0,2);
2686 float cy = cameraMatrixK.at<
double>(1,2);
2688 cv::Mat registered = cv::Mat::zeros(imageSize, CV_32FC1);
2692 for(
int i=0; i<laserScan.cols; ++i)
2694 const float* ptr = laserScan.ptr<
float>(0, i);
2698 if(laserScan.type() == CV_32FC2 || laserScan.type() == CV_32FC(5))
2719 float invZ = 1.0f/z;
2720 float dx = (fx*ptScan.x)*invZ + cx;
2721 float dy = (fy*ptScan.y)*invZ + cy;
2724 int dx_high = dx + 0.5f;
2725 int dy_high = dy + 0.5f;
2729 float &zReg = registered.at<
float>(dy_low, dx_low);
2730 if(zReg == 0 || z < zReg)
2736 if((dx_low != dx_high || dy_low != dy_high) &&
2739 float &zReg = registered.at<
float>(dy_high, dx_high);
2740 if(zReg == 0 || z < zReg)
2752 UDEBUG(
"Points in camera=%d/%d", count, laserScan.cols);
2758 const cv::Size & imageSize,
2759 const cv::Mat & cameraMatrixK,
2760 const pcl::PointCloud<pcl::PointXYZ>::Ptr laserScan,
2765 UASSERT(cameraMatrixK.type() == CV_64FC1 && cameraMatrixK.cols == 3 && cameraMatrixK.cols == 3);
2767 float fx = cameraMatrixK.at<
double>(0,0);
2768 float fy = cameraMatrixK.at<
double>(1,1);
2769 float cx = cameraMatrixK.at<
double>(0,2);
2770 float cy = cameraMatrixK.at<
double>(1,2);
2772 cv::Mat registered = cv::Mat::zeros(imageSize, CV_32FC1);
2776 for(
int i=0; i<(int)laserScan->size(); ++i)
2779 pcl::PointXYZ ptScan = laserScan->at(i);
2787 float invZ = 1.0f/z;
2788 float dx = (fx*ptScan.x)*invZ + cx;
2789 float dy = (fy*ptScan.y)*invZ + cy;
2792 int dx_high = dx + 0.5f;
2793 int dy_high = dy + 0.5f;
2797 float &zReg = registered.at<
float>(dy_low, dx_low);
2798 if(zReg == 0 || z < zReg)
2803 if((dx_low != dx_high || dy_low != dy_high) &&
2807 float &zReg = registered.at<
float>(dy_high, dx_high);
2808 if(zReg == 0 || z < zReg)
2819 UDEBUG(
"Points in camera=%d/%d", count, (
int)laserScan->size());
2825 const cv::Size & imageSize,
2826 const cv::Mat & cameraMatrixK,
2827 const pcl::PCLPointCloud2::Ptr laserScan,
2831 UASSERT(!laserScan->data.empty());
2832 UASSERT(cameraMatrixK.type() == CV_64FC1 && cameraMatrixK.cols == 3 && cameraMatrixK.cols == 3);
2834 float fx = cameraMatrixK.at<
double>(0,0);
2835 float fy = cameraMatrixK.at<
double>(1,1);
2836 float cx = cameraMatrixK.at<
double>(0,2);
2837 float cy = cameraMatrixK.at<
double>(1,2);
2839 cv::Mat registered = cv::Mat::zeros(imageSize, CV_32FC1);
2842 pcl::MsgFieldMap field_map;
2843 pcl::createMapping<pcl::PointXYZ> (laserScan->fields, field_map);
2846 if(field_map.size() == 1)
2850 const uint8_t* row_data = &laserScan->data[
row * laserScan->row_step];
2851 for (
uint32_t col = 0; col < laserScan->width; ++col)
2853 const uint8_t* msg_data = row_data + col * laserScan->point_step;
2854 pcl::PointXYZ ptScan;
2855 memcpy (&ptScan, msg_data + field_map.front().serialized_offset, field_map.front().size);
2863 float invZ = 1.0f/z;
2864 float dx = (fx*ptScan.x)*invZ + cx;
2865 float dy = (fy*ptScan.y)*invZ + cy;
2868 int dx_high = dx + 0.5f;
2869 int dy_high = dy + 0.5f;
2873 float &zReg = registered.at<
float>(dy_low, dx_low);
2874 if(zReg == 0 || z < zReg)
2879 if((dx_low != dx_high || dy_low != dy_high) &&
2883 float &zReg = registered.at<
float>(dy_high, dx_high);
2884 if(zReg == 0 || z < zReg)
2899 UERROR(
"field map pcl::pointXYZ not found!");
2947 UDEBUG(
"Points in camera=%d/%d", count, (
int)laserScan->data.size());
2954 UASSERT(registeredDepth.type() == CV_32FC1);
2955 if(verticalDirection)
2958 for(
int x=0; x<registeredDepth.cols; ++x)
2960 float valueA = 0.0f;
2962 for(
int y=0; y<registeredDepth.rows; ++y)
2964 float v = registeredDepth.at<
float>(y,x);
2965 if(fillToBorder && y == registeredDepth.rows-1 && v<=0.0f && indexA>=0)
2971 if(fillToBorder && indexA < 0)
2978 int range = y-indexA;
2981 float slope = (v-valueA)/(range);
2982 for(
int k=1; k<range; ++k)
2984 registeredDepth.at<
float>(indexA+k,x) = valueA+slope*
float(k);
2997 for(
int y=0; y<registeredDepth.rows; ++y)
2999 float valueA = 0.0f;
3001 for(
int x=0; x<registeredDepth.cols; ++x)
3003 float v = registeredDepth.at<
float>(y,x);
3004 if(fillToBorder && x == registeredDepth.cols-1 && v<=0.0f && indexA>=0)
3010 if(fillToBorder && indexA < 0)
3017 int range = x-indexA;
3020 float slope = (v-valueA)/(range);
3021 for(
int k=1; k<range; ++k)
3023 registeredDepth.at<
float>(y,indexA+k) = valueA+slope*
float(k);
3040 pcl::PointCloud<pcl::PointXYZ>::Ptr
concatenateClouds(
const std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr> & clouds)
3042 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZ>);
3043 for(std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr>::const_iterator iter = clouds.begin(); iter!=clouds.end(); ++iter)
3050 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
concatenateClouds(
const std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds)
3052 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
3053 for(std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr>::const_iterator iter = clouds.begin(); iter!=clouds.end(); ++iter)
3060 pcl::IndicesPtr
concatenate(
const std::vector<pcl::IndicesPtr> & indices)
3063 unsigned int totalSize = 0;
3064 for(
unsigned int i=0; i<indices.size(); ++i)
3066 totalSize += (
unsigned int)indices[i]->size();
3068 pcl::IndicesPtr ind(
new std::vector<int>(totalSize));
3069 unsigned int io = 0;
3070 for(
unsigned int i=0; i<indices.size(); ++i)
3072 for(
unsigned int j=0; j<indices[i]->size(); ++j)
3074 ind->at(io++) = indices[i]->at(j);
3080 pcl::IndicesPtr
concatenate(
const pcl::IndicesPtr & indicesA,
const pcl::IndicesPtr & indicesB)
3082 pcl::IndicesPtr ind(
new std::vector<int>(*indicesA));
3083 ind->resize(ind->size()+indicesB->size());
3084 unsigned int oi = (
unsigned int)indicesA->size();
3085 for(
unsigned int i=0; i<indicesB->size(); ++i)
3087 ind->at(oi++) = indicesB->at(i);
3093 const std::string & fileName,
3094 const std::multimap<int, pcl::PointXYZ> & words,
3099 pcl::PointCloud<pcl::PointXYZ> cloud;
3100 cloud.resize(words.size());
3102 for(std::multimap<int, pcl::PointXYZ>::const_iterator iter=words.begin(); iter!=words.end(); ++iter)
3106 pcl::io::savePCDFile(fileName, cloud);
3111 const std::string & fileName,
3112 const std::multimap<int, cv::Point3f> & words,
3117 pcl::PointCloud<pcl::PointXYZ> cloud;
3118 cloud.resize(words.size());
3120 for(std::multimap<int, cv::Point3f>::const_iterator iter=words.begin(); iter!=words.end(); ++iter)
3123 cloud[i++] = pcl::PointXYZ(pt.x, pt.y, pt.z);
3125 pcl::io::savePCDFile(fileName, cloud);
3136 UASSERT(bytes %
sizeof(
float) == 0);
3137 size_t num = bytes/
sizeof(float);
3139 output = cv::Mat(1, num/dim, CV_32FC(dim));
3143 stream = fopen (fileName.c_str(),
"rb");
3144 size_t actualReadNum = fread(output.data,
sizeof(
float),num,stream);
3145 UASSERT(num == actualReadNum);
3152 pcl::PointCloud<pcl::PointXYZ>::Ptr
loadBINCloud(
const std::string & fileName)
3157 pcl::PointCloud<pcl::PointXYZ>::Ptr
loadBINCloud(
const std::string & fileName,
int dim)
3171 pcl::PCLPointCloud2::Ptr cloud(
new pcl::PCLPointCloud2);
3172 pcl::io::loadPCDFile(path, *cloud);
3177 pcl::PCLPointCloud2::Ptr cloud(
new pcl::PCLPointCloud2);
3178 pcl::io::loadPLYFile(path, *cloud);
3185 const std::string & path,
3191 UDEBUG(
"Loading cloud (step=%d, voxel=%f m) : %s", downsampleStep, voxelSize, path.c_str());
3193 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZ>);
3200 pcl::io::loadPCDFile(path, *cloud);
3204 pcl::io::loadPLYFile(path, *cloud);
3206 int previousSize = (int)cloud->size();
3207 if(downsampleStep > 1 && cloud->size())
3210 UDEBUG(
"Downsampling scan (step=%d): %d -> %d", downsampleStep, previousSize, (
int)cloud->size());
3212 previousSize = (int)cloud->size();
3213 if(voxelSize > 0.0
f && cloud->size())
3216 UDEBUG(
"Voxel filtering scan (voxel=%f m): %d -> %d", voxelSize, previousSize, (
int)cloud->size());
cv::Mat RTABMAP_EXP disparityFromStereoImages(const cv::Mat &leftImage, const cv::Mat &rightImage, const ParametersMap ¶meters=ParametersMap())
LaserScan RTABMAP_EXP laserScanFromPointCloud(const pcl::PCLPointCloud2 &cloud, bool filterNaNs=true)
bool RTABMAP_EXP isFinite(const cv::Point3f &pt)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP cloudFromDisparity(const cv::Mat &imageDisparity, const StereoCameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
pcl::PointNormal RTABMAP_EXP laserScanToPointNormal(const LaserScan &laserScan, int index)
cv::Point3f RTABMAP_EXP projectDisparityTo3D(const cv::Point2f &pt, float disparity, const StereoCameraModel &model)
const cv::Size & imageSize() const
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
cv::Point3f RTABMAP_EXP transformPoint(const cv::Point3f &pt, const Transform &transform)
const cv::Mat & data() const
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP transformPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const Transform &transform)
void RTABMAP_EXP getMinMax3D(const cv::Mat &laserScan, cv::Point3f &min, cv::Point3f &max)
bool uIsInBounds(const T &value, const T &low, const T &high)
static int channels(Format format)
pcl::PointCloud< pcl::PointXYZRGBNormal >::Ptr RTABMAP_EXP laserScanToPointCloudRGBNormal(const LaserScan &laserScan, const Transform &transform=Transform(), unsigned char r=255, unsigned char g=255, unsigned char b=255)
pcl::PointXYZINormal RTABMAP_EXP laserScanToPointINormal(const LaserScan &laserScan, int index, float intensity)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP removeNaNFromPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud)
pcl::PCLPointCloud2::Ptr RTABMAP_EXP laserScanToPointCloud2(const LaserScan &laserScan, const Transform &transform=Transform())
GLM_FUNC_DECL bool all(vecType< bool, P > const &v)
std::map< std::string, std::string > ParametersMap
GLM_FUNC_DECL genType::row_type row(genType const &m, length_t const &index)
pcl::PointXYZ RTABMAP_EXP laserScanToPoint(const LaserScan &laserScan, int index)
int getNormalsOffset() const
Basic mathematics functions.
Some conversion functions.
void RTABMAP_EXP savePCDWords(const std::string &fileName, const std::multimap< int, pcl::PointXYZ > &words, const Transform &transform=Transform::getIdentity())
std::string getExtension()
pcl::PointXYZRGBNormal RTABMAP_EXP laserScanToPointRGBNormal(const LaserScan &laserScan, int index, unsigned char r, unsigned char g, unsigned char b)
const cv::Mat & imageRaw() const
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP laserScanToPointCloud(const LaserScan &laserScan, const Transform &transform=Transform())
pcl::PointCloud< pcl::PointXYZ > RTABMAP_EXP laserScanFromDepthImages(const cv::Mat &depthImages, const std::vector< CameraModel > &cameraModels, float maxDepth, float minDepth)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP cloudFromDepth(const cv::Mat &imageDepth, const CameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP cloudFromDepthRGB(const cv::Mat &imageRgb, const cv::Mat &imageDepth, const CameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
cv::Mat RTABMAP_EXP interpolate(const cv::Mat &image, int factor, float depthErrorRatio=0.02f)
LaserScan RTABMAP_EXP downsample(const LaserScan &cloud, int step)
cv::Mat RTABMAP_EXP laserScan2dFromPointCloud(const pcl::PointCloud< pcl::PointXYZ > &cloud, const Transform &transform=Transform(), bool filterNaNs=true)
bool uIsFinite(const T &value)
#define UASSERT(condition)
pcl::PointXYZ RTABMAP_EXP projectDepthTo3D(const cv::Mat &depthImage, float x, float y, float cx, float cy, float fx, float fy, bool smoothing, float depthErrorRatio=0.02f)
bool isValidForProjection() const
const CameraModel & left() const
#define UASSERT_MSG(condition, msg_str)
pcl::PointCloud< pcl::PointXYZINormal >::Ptr RTABMAP_EXP laserScanToPointCloudINormal(const LaserScan &laserScan, const Transform &transform=Transform(), float intensity=0.0f)
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP cloudRGBFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >())
GLM_FUNC_DECL genType abs(genType const &x)
pcl::PointXYZRGB RTABMAP_EXP laserScanToPointRGB(const LaserScan &laserScan, int index, unsigned char r=255, unsigned char g=255, unsigned char b=255)
cv::Rect RTABMAP_EXP computeRoi(const cv::Mat &image, const std::string &roiRatios)
bool isCompressed() const
pcl::PointCloud< pcl::PointXYZ > RTABMAP_EXP laserScanFromDepthImage(const cv::Mat &depthImage, float fx, float fy, float cx, float cy, float maxDepth=0, float minDepth=0, const Transform &localTransform=Transform::getIdentity())
pcl::PointXYZI RTABMAP_EXP laserScanToPointI(const LaserScan &laserScan, int index, float intensity)
CameraModel roi(const cv::Rect &roi) const
int getIntensityOffset() const
cv::Mat bgrFromCloud(const pcl::PointCloud< pcl::PointXYZRGBA > &cloud, bool bgrOrder)
bool isValidForProjection() const
const std::vector< CameraModel > & cameraModels() const
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP cloudFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >())
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
Eigen::Vector3f RTABMAP_EXP projectDepthTo3DRay(const cv::Size &imageSize, float x, float y, float cx, float cy, float fx, float fy)
const CameraModel & right() const
pcl::PointCloud< pcl::PointNormal >::Ptr RTABMAP_EXP laserScanToPointCloudNormal(const LaserScan &laserScan, const Transform &transform=Transform())
ULogger class and convenient macros.
const StereoCameraModel & stereoCameraModel() const
void RTABMAP_EXP fillProjectedCloudHoles(cv::Mat &depthRegistered, bool verticalDirection, bool fillToBorder)
cv::Mat RTABMAP_EXP projectCloudToCamera(const cv::Size &imageSize, const cv::Mat &cameraMatrixK, const cv::Mat &laserScan, const rtabmap::Transform &cameraTransform)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP loadBINCloud(const std::string &fileName)
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP cloudFromStereoImages(const cv::Mat &imageLeft, const cv::Mat &imageRight, const StereoCameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap ¶meters=ParametersMap())
pcl::PointCloud< pcl::PointXYZI >::Ptr RTABMAP_EXP laserScanToPointCloudI(const LaserScan &laserScan, const Transform &transform=Transform(), float intensity=0.0f)
float RTABMAP_EXP getDepth(const cv::Mat &depthImage, float x, float y, bool smoothing, float depthErrorRatio=0.02f, bool estWithNeighborsIfNull=false)
pcl::IndicesPtr RTABMAP_EXP concatenate(const std::vector< pcl::IndicesPtr > &indices)
Concatenate a vector of indices to a single vector.
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP cloudFromDisparityRGB(const cv::Mat &imageRgb, const cv::Mat &imageDisparity, const StereoCameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP voxelize(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const pcl::IndicesPtr &indices, float voxelSize)
LaserScan RTABMAP_EXP loadScan(const std::string &path)
std::string UTILITE_EXP uFormat(const char *fmt,...)
pcl::PointCloud< pcl::PointXYZ >::Ptr loadCloud(const std::string &path, const Transform &transform, int downsampleStep, float voxelSize)
void RTABMAP_EXP rgbdFromCloud(const pcl::PointCloud< pcl::PointXYZRGBA > &cloud, cv::Mat &rgb, cv::Mat &depth, float &fx, float &fy, bool bgrOrder=true, bool depth16U=true)
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP laserScanToPointCloudRGB(const LaserScan &laserScan, const Transform &transform=Transform(), unsigned char r=255, unsigned char g=255, unsigned char b=255)
bool hasIntensity() const
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP concatenateClouds(const std::list< pcl::PointCloud< pcl::PointXYZ >::Ptr > &clouds)
cv::Mat RTABMAP_EXP depthFromCloud(const pcl::PointCloud< pcl::PointXYZRGBA > &cloud, float &fx, float &fy, bool depth16U=true)
const Transform & localTransform() const
cv::Mat RTABMAP_EXP loadBINScan(const std::string &fileName)