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>);
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};
1274 #if PCL_VERSION_COMPARE(>=, 1, 10, 0) 1279 for(
unsigned int i=0; i<cloud.fields.size(); ++i)
1281 if(cloud.fields[i].name.compare(
"x") == 0)
1284 fieldOffsets[0] = cloud.fields[i].offset;
1286 else if(cloud.fields[i].name.compare(
"y") == 0)
1289 fieldOffsets[1] = cloud.fields[i].offset;
1291 else if(cloud.fields[i].name.compare(
"z") == 0 && !is2D)
1294 fieldOffsets[2] = cloud.fields[i].offset;
1296 else if(cloud.fields[i].name.compare(
"normal_x") == 0)
1299 fieldOffsets[3] = cloud.fields[i].offset;
1301 else if(cloud.fields[i].name.compare(
"normal_y") == 0)
1304 fieldOffsets[4] = cloud.fields[i].offset;
1306 else if(cloud.fields[i].name.compare(
"normal_z") == 0)
1309 fieldOffsets[5] = cloud.fields[i].offset;
1311 else if(cloud.fields[i].name.compare(
"rgb") == 0 || cloud.fields[i].name.compare(
"rgba") == 0)
1314 fieldOffsets[6] = cloud.fields[i].offset;
1316 else if(cloud.fields[i].name.compare(
"intensity") == 0)
1319 fieldOffsets[7] = cloud.fields[i].offset;
1323 UDEBUG(
"Ignoring \"%s\" field", cloud.fields[i].name.c_str());
1326 if(fieldStates[0]==0 || fieldStates[1]==0)
1329 UERROR(
"Cloud has not corresponding fields to laser scan!");
1333 bool hasNormals = fieldStates[3] || fieldStates[4] || fieldStates[5];
1334 bool hasIntensity = fieldStates[7];
1335 bool hasRGB = !hasIntensity&&fieldStates[6];
1336 bool is3D = fieldStates[0] && fieldStates[1] && fieldStates[2];
1339 int outputNormalOffset = 0;
1342 if(hasNormals && hasIntensity)
1345 outputNormalOffset = 4;
1347 else if(hasNormals && !hasIntensity && !hasRGB)
1350 outputNormalOffset = 3;
1352 else if(hasNormals && hasRGB)
1355 outputNormalOffset = 4;
1357 else if(!hasNormals && hasIntensity)
1361 else if(!hasNormals && hasRGB)
1372 if(hasNormals && hasIntensity)
1375 outputNormalOffset = 3;
1377 else if(hasNormals && !hasIntensity)
1380 outputNormalOffset = 2;
1382 else if(!hasNormals && hasIntensity)
1392 UASSERT(cloud.data.size()/cloud.point_step == (
uint32_t)cloud.height*cloud.width);
1393 cv::Mat laserScan = cv::Mat(1, (
int)cloud.data.size()/cloud.point_step, CV_32FC(
LaserScan::channels(format)));
1399 transformRot = transform.
rotation();
1404 const uint8_t* row_data = &cloud.data[
row * cloud.row_step];
1407 const uint8_t* msg_data = row_data + col * cloud.point_step;
1409 float * ptr = laserScan.ptr<
float>(0, oi);
1412 if(laserScan.channels() == 2)
1414 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1415 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1418 else if(laserScan.channels() == 3)
1420 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1421 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1424 ptr[2] = *(
float*)(msg_data + fieldOffsets[7]);
1428 ptr[2] = *(
float*)(msg_data + fieldOffsets[2]);
1432 else if(laserScan.channels() == 4)
1434 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1435 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1436 ptr[2] = *(
float*)(msg_data + fieldOffsets[2]);
1439 ptr[3] = *(
float*)(msg_data + fieldOffsets[7]);
1443 #if PCL_VERSION_COMPARE(>=, 1, 10, 0) 1452 int * ptrInt = (
int*)ptr;
1453 ptrInt[3] = int(b) | (int(g) << 8) | (
int(r) << 16);
1457 else if(laserScan.channels() == 5)
1459 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1460 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1461 ptr[2] = *(
float*)(msg_data + fieldOffsets[3]);
1462 ptr[3] = *(
float*)(msg_data + fieldOffsets[4]);
1463 ptr[4] = *(
float*)(msg_data + fieldOffsets[5]);
1466 else if(laserScan.channels() == 6)
1468 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1469 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1472 ptr[2] = *(
float*)(msg_data + fieldOffsets[7]);
1476 ptr[2] = *(
float*)(msg_data + fieldOffsets[2]);
1478 ptr[3] = *(
float*)(msg_data + fieldOffsets[3]);
1479 ptr[4] = *(
float*)(msg_data + fieldOffsets[4]);
1480 ptr[5] = *(
float*)(msg_data + fieldOffsets[5]);
1483 else if(laserScan.channels() == 7)
1485 ptr[0] = *(
float*)(msg_data + fieldOffsets[0]);
1486 ptr[1] = *(
float*)(msg_data + fieldOffsets[1]);
1487 ptr[2] = *(
float*)(msg_data + fieldOffsets[2]);
1490 ptr[3] = *(
float*)(msg_data + fieldOffsets[7]);
1494 #if PCL_VERSION_COMPARE(>=, 1, 10, 0) 1503 int * ptrInt = (
int*)ptr;
1504 ptrInt[3] = int(b) | (int(g) << 8) | (
int(r) << 16);
1506 ptr[4] = *(
float*)(msg_data + fieldOffsets[3]);
1507 ptr[5] = *(
float*)(msg_data + fieldOffsets[4]);
1508 ptr[6] = *(
float*)(msg_data + fieldOffsets[5]);
1513 UFATAL(
"Cannot handle as many channels (%d)!", laserScan.channels());
1516 if(!filterNaNs || valid)
1518 if(valid && transformValid)
1529 pt =
util3d::transformPoint(cv::Point3f(ptr[outputNormalOffset], ptr[outputNormalOffset+1], ptr[outputNormalOffset+2]), transformRot);
1530 ptr[outputNormalOffset] = pt.x;
1531 ptr[outputNormalOffset+1] = pt.y;
1532 ptr[outputNormalOffset+2] = pt.z;
1555 Eigen::Affine3f transform3f = transform.
toEigen3f();
1559 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC3);
1560 for(
unsigned int i=0; i<indices->size(); ++i)
1562 int index = indices->at(i);
1565 float * ptr = laserScan.ptr<
float>(0, oi++);
1575 ptr[0] = cloud.at(index).x;
1576 ptr[1] = cloud.at(index).y;
1577 ptr[2] = cloud.at(index).z;
1584 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC3);
1585 for(
unsigned int i=0; i<cloud.size(); ++i)
1589 float * ptr = laserScan.ptr<
float>(0, oi++);
1599 ptr[0] = cloud.at(i).x;
1600 ptr[1] = cloud.at(i).y;
1601 ptr[2] = cloud.at(i).z;
1624 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC(6));
1625 for(
unsigned int i=0; i<indices->size(); ++i)
1627 int index = indices->at(i);
1633 float * ptr = laserScan.ptr<
float>(0, oi++);
1640 ptr[3] = pt.normal_x;
1641 ptr[4] = pt.normal_y;
1642 ptr[5] = pt.normal_z;
1646 ptr[0] = cloud.at(index).x;
1647 ptr[1] = cloud.at(index).y;
1648 ptr[2] = cloud.at(index).z;
1649 ptr[3] = cloud.at(index).normal_x;
1650 ptr[4] = cloud.at(index).normal_y;
1651 ptr[5] = cloud.at(index).normal_z;
1658 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(6));
1659 for(
unsigned int i=0; i<cloud.size(); ++i)
1666 float * ptr = laserScan.ptr<
float>(0, oi++);
1673 ptr[3] = pt.normal_x;
1674 ptr[4] = pt.normal_y;
1675 ptr[5] = pt.normal_z;
1679 ptr[0] = cloud.at(i).x;
1680 ptr[1] = cloud.at(i).y;
1681 ptr[2] = cloud.at(i).z;
1682 ptr[3] = cloud.at(i).normal_x;
1683 ptr[4] = cloud.at(i).normal_y;
1684 ptr[5] = cloud.at(i).normal_z;
1698 UASSERT(cloud.size() == normals.size());
1699 cv::Mat laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(6));
1702 for(
unsigned int i=0; i<cloud.size(); ++i)
1706 float * ptr = laserScan.ptr<
float>(0, oi++);
1709 pcl::PointNormal pt;
1710 pt.x = cloud.at(i).x;
1711 pt.y = cloud.at(i).y;
1712 pt.z = cloud.at(i).z;
1713 pt.normal_x = normals.at(i).normal_x;
1714 pt.normal_y = normals.at(i).normal_y;
1715 pt.normal_z = normals.at(i).normal_z;
1720 ptr[3] = pt.normal_x;
1721 ptr[4] = pt.normal_y;
1722 ptr[5] = pt.normal_z;
1726 ptr[0] = cloud.at(i).x;
1727 ptr[1] = cloud.at(i).y;
1728 ptr[2] = cloud.at(i).z;
1729 ptr[3] = normals.at(i).normal_x;
1730 ptr[4] = normals.at(i).normal_y;
1731 ptr[5] = normals.at(i).normal_z;
1751 Eigen::Affine3f transform3f = transform.
toEigen3f();
1755 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC(4));
1756 for(
unsigned int i=0; i<indices->size(); ++i)
1758 int index = indices->at(i);
1761 float * ptr = laserScan.ptr<
float>(0, oi++);
1771 ptr[0] = cloud.at(index).x;
1772 ptr[1] = cloud.at(index).y;
1773 ptr[2] = cloud.at(index).z;
1775 int * ptrInt = (
int*)ptr;
1776 ptrInt[3] = int(cloud.at(index).b) | (
int(cloud.at(index).g) << 8) | (int(cloud.at(index).r) << 16);
1782 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(4));
1783 for(
unsigned int i=0; i<cloud.size(); ++i)
1787 float * ptr = laserScan.ptr<
float>(0, oi++);
1797 ptr[0] = cloud.at(i).x;
1798 ptr[1] = cloud.at(i).y;
1799 ptr[2] = cloud.at(i).z;
1801 int * ptrInt = (
int*)ptr;
1802 ptrInt[3] = int(cloud.at(i).b) | (
int(cloud.at(i).g) << 8) | (int(cloud.at(i).r) << 16);
1822 Eigen::Affine3f transform3f = transform.
toEigen3f();
1826 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC(4));
1827 for(
unsigned int i=0; i<indices->size(); ++i)
1829 int index = indices->at(i);
1832 float * ptr = laserScan.ptr<
float>(0, oi++);
1842 ptr[0] = cloud.at(index).x;
1843 ptr[1] = cloud.at(index).y;
1844 ptr[2] = cloud.at(index).z;
1846 ptr[3] = cloud.at(index).intensity;
1852 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(4));
1853 for(
unsigned int i=0; i<cloud.size(); ++i)
1857 float * ptr = laserScan.ptr<
float>(0, oi++);
1867 ptr[0] = cloud.at(i).x;
1868 ptr[1] = cloud.at(i).y;
1869 ptr[2] = cloud.at(i).z;
1871 ptr[3] = cloud.at(i).intensity;
1884 UASSERT(cloud.size() == normals.size());
1885 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(7));
1888 for(
unsigned int i=0; i<cloud.size(); ++i)
1892 float * ptr = laserScan.ptr<
float>(0, oi++);
1895 pcl::PointXYZRGBNormal pt;
1896 pt.x = cloud.at(i).x;
1897 pt.y = cloud.at(i).y;
1898 pt.z = cloud.at(i).z;
1899 pt.normal_x = normals.at(i).normal_x;
1900 pt.normal_y = normals.at(i).normal_y;
1901 pt.normal_z = normals.at(i).normal_z;
1906 ptr[4] = pt.normal_x;
1907 ptr[5] = pt.normal_y;
1908 ptr[6] = pt.normal_z;
1912 ptr[0] = cloud.at(i).x;
1913 ptr[1] = cloud.at(i).y;
1914 ptr[2] = cloud.at(i).z;
1915 ptr[4] = normals.at(i).normal_x;
1916 ptr[5] = normals.at(i).normal_y;
1917 ptr[6] = normals.at(i).normal_z;
1919 int * ptrInt = (
int*)ptr;
1920 ptrInt[3] = int(cloud.at(i).b) | (
int(cloud.at(i).g) << 8) | (int(cloud.at(i).r) << 16);
1941 laserScan = cv::Mat(1, (
int)indices->size(), CV_32FC(7));
1942 for(
unsigned int i=0; i<indices->size(); ++i)
1944 int index = indices->at(i);
1950 float * ptr = laserScan.ptr<
float>(0, oi++);
1957 ptr[4] = pt.normal_x;
1958 ptr[5] = pt.normal_y;
1959 ptr[6] = pt.normal_z;
1963 ptr[0] = cloud.at(index).x;
1964 ptr[1] = cloud.at(index).y;
1965 ptr[2] = cloud.at(index).z;
1966 ptr[4] = cloud.at(index).normal_x;
1967 ptr[5] = cloud.at(index).normal_y;
1968 ptr[6] = cloud.at(index).normal_z;
1970 int * ptrInt = (
int*)ptr;
1971 ptrInt[3] = int(cloud.at(index).b) | (
int(cloud.at(index).g) << 8) | (int(cloud.at(index).r) << 16);
1977 laserScan = cv::Mat(1, (
int)cloud.size(), CV_32FC(7));
1978 for(
unsigned int i=0; i<cloud.size(); ++i)
1985 float * ptr = laserScan.ptr<
float>(0, oi++);
1992 ptr[4] = pt.normal_x;
1993 ptr[5] = pt.normal_y;
1994 ptr[6] = pt.normal_z;
1998 ptr[0] = cloud.at(i).x;
1999 ptr[1] = cloud.at(i).y;
2000 ptr[2] = cloud.at(i).z;
2001 ptr[4] = cloud.at(i).normal_x;
2002 ptr[5] = cloud.at(i).normal_y;
2003 ptr[6] = cloud.at(i).normal_z;
2005 int * ptrInt = (
int*)ptr;
2006 ptrInt[3] = int(cloud.at(i).b) | (
int(cloud.at(i).g) << 8) | (int(cloud.at(i).r) << 16);
2019 UASSERT(cloud.size() == normals.size());
2020 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(7));
2023 for(
unsigned int i=0; i<cloud.size(); ++i)
2027 float * ptr = laserScan.ptr<
float>(0, oi++);
2030 pcl::PointXYZINormal pt;
2031 pt.x = cloud.at(i).x;
2032 pt.y = cloud.at(i).y;
2033 pt.z = cloud.at(i).z;
2034 pt.normal_x = normals.at(i).normal_x;
2035 pt.normal_y = normals.at(i).normal_y;
2036 pt.normal_z = normals.at(i).normal_z;
2041 ptr[4] = pt.normal_x;
2042 ptr[5] = pt.normal_y;
2043 ptr[6] = pt.normal_z;
2047 ptr[0] = cloud.at(i).x;
2048 ptr[1] = cloud.at(i).y;
2049 ptr[2] = cloud.at(i).z;
2050 ptr[4] = normals.at(i).normal_x;
2051 ptr[5] = normals.at(i).normal_y;
2052 ptr[6] = normals.at(i).normal_z;
2054 ptr[3] = cloud.at(i).intensity;
2065 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(7));
2068 for(
unsigned int i=0; i<cloud.size(); ++i)
2075 float * ptr = laserScan.ptr<
float>(0, oi++);
2082 ptr[4] = pt.normal_x;
2083 ptr[5] = pt.normal_y;
2084 ptr[6] = pt.normal_z;
2088 ptr[0] = cloud.at(i).x;
2089 ptr[1] = cloud.at(i).y;
2090 ptr[2] = cloud.at(i).z;
2091 ptr[4] = cloud.at(i).normal_x;
2092 ptr[5] = cloud.at(i).normal_y;
2093 ptr[6] = cloud.at(i).normal_z;
2095 ptr[3] = cloud.at(i).intensity;
2107 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC2);
2108 bool nullTransform = transform.
isNull();
2109 Eigen::Affine3f transform3f = transform.
toEigen3f();
2111 for(
unsigned int i=0; i<cloud.size(); ++i)
2115 float * ptr = laserScan.ptr<
float>(0, oi++);
2124 ptr[0] = cloud.at(i).x;
2125 ptr[1] = cloud.at(i).y;
2139 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC3);
2140 bool nullTransform = transform.
isNull();
2141 Eigen::Affine3f transform3f = transform.
toEigen3f();
2143 for(
unsigned int i=0; i<cloud.size(); ++i)
2147 float * ptr = laserScan.ptr<
float>(0, oi++);
2153 ptr[2] = pt.intensity;
2157 ptr[0] = cloud.at(i).x;
2158 ptr[1] = cloud.at(i).y;
2159 ptr[2] = cloud.at(i).intensity;
2173 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(5));
2174 bool nullTransform = transform.
isNull();
2176 for(
unsigned int i=0; i<cloud.size(); ++i)
2183 float * ptr = laserScan.ptr<
float>(0, oi++);
2189 ptr[2] = pt.normal_x;
2190 ptr[3] = pt.normal_y;
2191 ptr[4] = pt.normal_z;
2195 const pcl::PointNormal & pt = cloud.at(i);
2198 ptr[2] = pt.normal_x;
2199 ptr[3] = pt.normal_y;
2200 ptr[4] = pt.normal_z;
2213 UASSERT(cloud.size() == normals.size());
2214 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(5));
2217 for(
unsigned int i=0; i<cloud.size(); ++i)
2221 float * ptr = laserScan.ptr<
float>(0, oi++);
2224 pcl::PointNormal pt;
2225 pt.x = cloud.at(i).x;
2226 pt.y = cloud.at(i).y;
2227 pt.z = cloud.at(i).z;
2228 pt.normal_x = normals.at(i).normal_x;
2229 pt.normal_y = normals.at(i).normal_y;
2230 pt.normal_z = normals.at(i).normal_z;
2234 ptr[2] = pt.normal_x;
2235 ptr[3] = pt.normal_y;
2236 ptr[4] = pt.normal_z;
2240 ptr[0] = cloud.at(i).x;
2241 ptr[1] = cloud.at(i).y;
2242 ptr[2] = normals.at(i).normal_x;
2243 ptr[3] = normals.at(i).normal_y;
2244 ptr[4] = normals.at(i).normal_z;
2257 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(6));
2258 bool nullTransform = transform.
isNull();
2260 for(
unsigned int i=0; i<cloud.size(); ++i)
2267 float * ptr = laserScan.ptr<
float>(0, oi++);
2273 ptr[2] = pt.intensity;
2274 ptr[3] = pt.normal_x;
2275 ptr[4] = pt.normal_y;
2276 ptr[5] = pt.normal_z;
2280 const pcl::PointXYZINormal & pt = cloud.at(i);
2283 ptr[2] = pt.intensity;
2284 ptr[3] = pt.normal_x;
2285 ptr[4] = pt.normal_y;
2286 ptr[5] = pt.normal_z;
2299 UASSERT(cloud.size() == normals.size());
2300 cv::Mat laserScan(1, (
int)cloud.size(), CV_32FC(6));
2303 for(
unsigned int i=0; i<cloud.size(); ++i)
2307 float * ptr = laserScan.ptr<
float>(0, oi++);
2310 pcl::PointXYZINormal pt;
2311 pt.x = cloud.at(i).x;
2312 pt.y = cloud.at(i).y;
2313 pt.z = cloud.at(i).z;
2314 pt.normal_x = normals.at(i).normal_x;
2315 pt.normal_y = normals.at(i).normal_y;
2316 pt.normal_z = normals.at(i).normal_z;
2320 ptr[2] = pt.intensity;
2321 ptr[3] = pt.normal_x;
2322 ptr[4] = pt.normal_y;
2323 ptr[5] = pt.normal_z;
2327 ptr[0] = cloud.at(i).x;
2328 ptr[1] = cloud.at(i).y;
2329 ptr[2] = cloud.at(i).intensity;
2330 ptr[3] = normals.at(i).normal_x;
2331 ptr[4] = normals.at(i).normal_y;
2332 ptr[5] = normals.at(i).normal_z;
2345 pcl::PCLPointCloud2::Ptr cloud(
new pcl::PCLPointCloud2);
2377 UERROR(
"Unknown conversion from LaserScan format %d to PointCloud2.", laserScan.
format());
2384 pcl::PointCloud<pcl::PointXYZ>::Ptr output(
new pcl::PointCloud<pcl::PointXYZ>);
2385 output->resize(laserScan.
size());
2386 output->is_dense =
true;
2387 bool nullTransform = transform.
isNull();
2388 Eigen::Affine3f transform3f = transform.
toEigen3f();
2389 for(
int i=0; i<laserScan.
size(); ++i)
2402 pcl::PointCloud<pcl::PointNormal>::Ptr output(
new pcl::PointCloud<pcl::PointNormal>);
2403 output->resize(laserScan.
size());
2404 output->is_dense =
true;
2405 bool nullTransform = transform.
isNull();
2406 for(
int i=0; i<laserScan.
size(); ++i)
2419 pcl::PointCloud<pcl::PointXYZRGB>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGB>);
2420 output->resize(laserScan.
size());
2421 output->is_dense =
true;
2423 Eigen::Affine3f transform3f = transform.
toEigen3f();
2424 for(
int i=0; i<laserScan.
size(); ++i)
2437 pcl::PointCloud<pcl::PointXYZI>::Ptr output(
new pcl::PointCloud<pcl::PointXYZI>);
2438 output->resize(laserScan.
size());
2439 output->is_dense =
true;
2441 Eigen::Affine3f transform3f = transform.
toEigen3f();
2442 for(
int i=0; i<laserScan.
size(); ++i)
2455 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
2456 output->resize(laserScan.
size());
2457 output->is_dense =
true;
2459 for(
int i=0; i<laserScan.
size(); ++i)
2472 pcl::PointCloud<pcl::PointXYZINormal>::Ptr output(
new pcl::PointCloud<pcl::PointXYZINormal>);
2473 output->resize(laserScan.
size());
2474 output->is_dense =
true;
2476 for(
int i=0; i<laserScan.
size(); ++i)
2490 pcl::PointXYZ output;
2491 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2494 if(!laserScan.
is2d())
2504 pcl::PointNormal output;
2505 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2508 if(!laserScan.
is2d())
2515 output.normal_x = ptr[offset];
2516 output.normal_y = ptr[offset+1];
2517 output.normal_z = ptr[offset+2];
2525 pcl::PointXYZRGB 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);
2545 int * ptrInt = (
int*)ptr;
2547 output.r = (
unsigned char)(ptrInt[indexIntensity] & 0xFF);
2548 output.g = (
unsigned char)((ptrInt[indexIntensity] >> 8) & 0xFF);
2549 output.b = (
unsigned char)((ptrInt[indexIntensity] >> 16) & 0xFF);
2550 output.a = (
unsigned char)((ptrInt[indexIntensity] >> 24) & 0xFF);
2564 pcl::PointXYZI output;
2565 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2568 if(!laserScan.
is2d())
2576 output.intensity = ptr[offset];
2580 output.intensity = intensity;
2589 pcl::PointXYZRGBNormal output;
2590 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2593 if(!laserScan.
is2d())
2600 int * ptrInt = (
int*)ptr;
2602 output.b = (
unsigned char)(ptrInt[indexRGB] & 0xFF);
2603 output.g = (
unsigned char)((ptrInt[indexRGB] >> 8) & 0xFF);
2604 output.r = (
unsigned char)((ptrInt[indexRGB] >> 16) & 0xFF);
2608 int * ptrInt = (
int*)ptr;
2610 output.r = (
unsigned char)(ptrInt[indexIntensity] & 0xFF);
2611 output.g = (
unsigned char)((ptrInt[indexIntensity] >> 8) & 0xFF);
2612 output.b = (
unsigned char)((ptrInt[indexIntensity] >> 16) & 0xFF);
2613 output.a = (
unsigned char)((ptrInt[indexIntensity] >> 24) & 0xFF);
2625 output.normal_x = ptr[offset];
2626 output.normal_y = ptr[offset+1];
2627 output.normal_z = ptr[offset+2];
2636 pcl::PointXYZINormal output;
2637 const float * ptr = laserScan.
data().ptr<
float>(0, index);
2640 if(!laserScan.
is2d())
2648 output.intensity = ptr[offset];
2652 output.intensity = intensity;
2658 output.normal_x = ptr[offset];
2659 output.normal_y = ptr[offset+1];
2660 output.normal_z = ptr[offset+2];
2669 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));
2671 const float * ptr = laserScan.ptr<
float>(0, 0);
2672 min.x = max.x = ptr[0];
2673 min.y = max.y = ptr[1];
2674 bool is3d = laserScan.channels() >= 3 && laserScan.channels() != 5;
2675 min.z = max.z = is3d?ptr[2]:0.0f;
2676 for(
int i=1; i<laserScan.cols; ++i)
2678 ptr = laserScan.ptr<
float>(0, i);
2680 if(ptr[0] < min.x) min.x = ptr[0];
2681 else if(ptr[0] > max.x) max.x = ptr[0];
2683 if(ptr[1] < min.y) min.y = ptr[1];
2684 else if(ptr[1] > max.y) max.y = ptr[1];
2688 if(ptr[2] < min.z) min.z = ptr[2];
2689 else if(ptr[2] > max.z) max.z = ptr[2];
2695 cv::Point3f minCV, maxCV;
2707 const cv::Point2f & pt,
2711 if(disparity > 0.0
f && model.
baseline() > 0.0f && model.
left().
fx() > 0.0f)
2719 float W = model.
baseline()/(disparity + c);
2720 return cv::Point3f((pt.x - model.
left().
cx())*W, (pt.y - model.
left().
cy())*W, model.
left().
fx()*W);
2722 float bad_point = std::numeric_limits<float>::quiet_NaN ();
2723 return cv::Point3f(bad_point, bad_point, bad_point);
2727 const cv::Point2f & pt,
2728 const cv::Mat & disparity,
2731 UASSERT(!disparity.empty() && (disparity.type() == CV_32FC1 || disparity.type() == CV_16SC1));
2732 int u = int(pt.x+0.5f);
2733 int v = int(pt.y+0.5f);
2734 float bad_point = std::numeric_limits<float>::quiet_NaN ();
2738 float d = disparity.type() == CV_16SC1?float(disparity.at<
short>(v,u))/16.0f:disparity.at<
float>(v,u);
2741 return cv::Point3f(bad_point, bad_point, bad_point);
2746 const cv::Size & imageSize,
2747 const cv::Mat & cameraMatrixK,
2748 const cv::Mat & laserScan,
2753 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));
2754 UASSERT(cameraMatrixK.type() == CV_64FC1 && cameraMatrixK.cols == 3 && cameraMatrixK.cols == 3);
2756 float fx = cameraMatrixK.at<
double>(0,0);
2757 float fy = cameraMatrixK.at<
double>(1,1);
2758 float cx = cameraMatrixK.at<
double>(0,2);
2759 float cy = cameraMatrixK.at<
double>(1,2);
2761 cv::Mat registered = cv::Mat::zeros(imageSize, CV_32FC1);
2765 for(
int i=0; i<laserScan.cols; ++i)
2767 const float* ptr = laserScan.ptr<
float>(0, i);
2771 if(laserScan.type() == CV_32FC2 || laserScan.type() == CV_32FC(5))
2792 float invZ = 1.0f/z;
2793 float dx = (fx*ptScan.x)*invZ + cx;
2794 float dy = (fy*ptScan.y)*invZ + cy;
2797 int dx_high = dx + 0.5f;
2798 int dy_high = dy + 0.5f;
2802 float &zReg = registered.at<
float>(dy_low, dx_low);
2803 if(zReg == 0 || z < zReg)
2809 if((dx_low != dx_high || dy_low != dy_high) &&
2812 float &zReg = registered.at<
float>(dy_high, dx_high);
2813 if(zReg == 0 || z < zReg)
2825 UDEBUG(
"Points in camera=%d/%d", count, laserScan.cols);
2831 const cv::Size & imageSize,
2832 const cv::Mat & cameraMatrixK,
2833 const pcl::PointCloud<pcl::PointXYZ>::Ptr laserScan,
2838 UASSERT(cameraMatrixK.type() == CV_64FC1 && cameraMatrixK.cols == 3 && cameraMatrixK.cols == 3);
2840 float fx = cameraMatrixK.at<
double>(0,0);
2841 float fy = cameraMatrixK.at<
double>(1,1);
2842 float cx = cameraMatrixK.at<
double>(0,2);
2843 float cy = cameraMatrixK.at<
double>(1,2);
2845 cv::Mat registered = cv::Mat::zeros(imageSize, CV_32FC1);
2849 for(
int i=0; i<(int)laserScan->size(); ++i)
2852 pcl::PointXYZ ptScan = laserScan->at(i);
2860 float invZ = 1.0f/z;
2861 float dx = (fx*ptScan.x)*invZ + cx;
2862 float dy = (fy*ptScan.y)*invZ + cy;
2865 int dx_high = dx + 0.5f;
2866 int dy_high = dy + 0.5f;
2870 float &zReg = registered.at<
float>(dy_low, dx_low);
2871 if(zReg == 0 || z < zReg)
2876 if((dx_low != dx_high || dy_low != dy_high) &&
2880 float &zReg = registered.at<
float>(dy_high, dx_high);
2881 if(zReg == 0 || z < zReg)
2892 UDEBUG(
"Points in camera=%d/%d", count, (
int)laserScan->size());
2898 const cv::Size & imageSize,
2899 const cv::Mat & cameraMatrixK,
2900 const pcl::PCLPointCloud2::Ptr laserScan,
2904 UASSERT(!laserScan->data.empty());
2905 UASSERT(cameraMatrixK.type() == CV_64FC1 && cameraMatrixK.cols == 3 && cameraMatrixK.cols == 3);
2907 float fx = cameraMatrixK.at<
double>(0,0);
2908 float fy = cameraMatrixK.at<
double>(1,1);
2909 float cx = cameraMatrixK.at<
double>(0,2);
2910 float cy = cameraMatrixK.at<
double>(1,2);
2912 cv::Mat registered = cv::Mat::zeros(imageSize, CV_32FC1);
2915 pcl::MsgFieldMap field_map;
2916 pcl::createMapping<pcl::PointXYZ> (laserScan->fields, field_map);
2919 if(field_map.size() == 1)
2923 const uint8_t* row_data = &laserScan->data[
row * laserScan->row_step];
2926 const uint8_t* msg_data = row_data + col * laserScan->point_step;
2927 pcl::PointXYZ ptScan;
2928 memcpy (&ptScan, msg_data + field_map.front().serialized_offset, field_map.front().size);
2936 float invZ = 1.0f/z;
2937 float dx = (fx*ptScan.x)*invZ + cx;
2938 float dy = (fy*ptScan.y)*invZ + cy;
2941 int dx_high = dx + 0.5f;
2942 int dy_high = dy + 0.5f;
2946 float &zReg = registered.at<
float>(dy_low, dx_low);
2947 if(zReg == 0 || z < zReg)
2952 if((dx_low != dx_high || dy_low != dy_high) &&
2956 float &zReg = registered.at<
float>(dy_high, dx_high);
2957 if(zReg == 0 || z < zReg)
2972 UERROR(
"field map pcl::pointXYZ not found!");
3020 UDEBUG(
"Points in camera=%d/%d", count, (
int)laserScan->data.size());
3027 UASSERT(registeredDepth.type() == CV_32FC1);
3028 if(verticalDirection)
3031 for(
int x=0; x<registeredDepth.cols; ++x)
3033 float valueA = 0.0f;
3035 for(
int y=0; y<registeredDepth.rows; ++y)
3037 float v = registeredDepth.at<
float>(y,x);
3038 if(fillToBorder && y == registeredDepth.rows-1 && v<=0.0f && indexA>=0)
3044 if(fillToBorder && indexA < 0)
3051 int range = y-indexA;
3054 float slope = (v-valueA)/(range);
3055 for(
int k=1; k<range; ++k)
3057 registeredDepth.at<
float>(indexA+k,x) = valueA+slope*
float(k);
3070 for(
int y=0; y<registeredDepth.rows; ++y)
3072 float valueA = 0.0f;
3074 for(
int x=0; x<registeredDepth.cols; ++x)
3076 float v = registeredDepth.at<
float>(y,x);
3077 if(fillToBorder && x == registeredDepth.cols-1 && v<=0.0f && indexA>=0)
3083 if(fillToBorder && indexA < 0)
3090 int range = x-indexA;
3093 float slope = (v-valueA)/(range);
3094 for(
int k=1; k<range; ++k)
3096 registeredDepth.at<
float>(y,indexA+k) = valueA+slope*
float(k);
3113 pcl::PointCloud<pcl::PointXYZ>::Ptr
concatenateClouds(
const std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr> & clouds)
3115 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZ>);
3116 for(std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr>::const_iterator iter = clouds.begin(); iter!=clouds.end(); ++iter)
3123 pcl::PointCloud<pcl::PointXYZRGB>::Ptr
concatenateClouds(
const std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds)
3125 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
3126 for(std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr>::const_iterator iter = clouds.begin(); iter!=clouds.end(); ++iter)
3133 pcl::IndicesPtr
concatenate(
const std::vector<pcl::IndicesPtr> & indices)
3136 unsigned int totalSize = 0;
3137 for(
unsigned int i=0; i<indices.size(); ++i)
3139 totalSize += (
unsigned int)indices[i]->size();
3141 pcl::IndicesPtr ind(
new std::vector<int>(totalSize));
3142 unsigned int io = 0;
3143 for(
unsigned int i=0; i<indices.size(); ++i)
3145 for(
unsigned int j=0; j<indices[i]->size(); ++j)
3147 ind->at(io++) = indices[i]->at(j);
3153 pcl::IndicesPtr
concatenate(
const pcl::IndicesPtr & indicesA,
const pcl::IndicesPtr & indicesB)
3155 pcl::IndicesPtr ind(
new std::vector<int>(*indicesA));
3156 ind->resize(ind->size()+indicesB->size());
3157 unsigned int oi = (
unsigned int)indicesA->size();
3158 for(
unsigned int i=0; i<indicesB->size(); ++i)
3160 ind->at(oi++) = indicesB->at(i);
3166 const std::string & fileName,
3167 const std::multimap<int, pcl::PointXYZ> & words,
3172 pcl::PointCloud<pcl::PointXYZ> cloud;
3173 cloud.resize(words.size());
3175 for(std::multimap<int, pcl::PointXYZ>::const_iterator iter=words.begin(); iter!=words.end(); ++iter)
3179 pcl::io::savePCDFile(fileName, cloud);
3184 const std::string & fileName,
3185 const std::multimap<int, cv::Point3f> & words,
3190 pcl::PointCloud<pcl::PointXYZ> cloud;
3191 cloud.resize(words.size());
3193 for(std::multimap<int, cv::Point3f>::const_iterator iter=words.begin(); iter!=words.end(); ++iter)
3196 cloud[i++] = pcl::PointXYZ(pt.x, pt.y, pt.z);
3198 pcl::io::savePCDFile(fileName, cloud);
3209 UASSERT(bytes %
sizeof(
float) == 0);
3210 size_t num = bytes/
sizeof(float);
3212 output = cv::Mat(1, num/dim, CV_32FC(dim));
3216 stream = fopen (fileName.c_str(),
"rb");
3217 size_t actualReadNum = fread(output.data,
sizeof(
float),num,stream);
3218 UASSERT(num == actualReadNum);
3225 pcl::PointCloud<pcl::PointXYZ>::Ptr
loadBINCloud(
const std::string & fileName)
3230 pcl::PointCloud<pcl::PointXYZ>::Ptr
loadBINCloud(
const std::string & fileName,
int dim)
3244 pcl::PCLPointCloud2::Ptr cloud(
new pcl::PCLPointCloud2);
3245 pcl::io::loadPCDFile(path, *cloud);
3250 pcl::PCLPointCloud2::Ptr cloud(
new pcl::PCLPointCloud2);
3251 pcl::io::loadPLYFile(path, *cloud);
3258 const std::string & path,
3264 UDEBUG(
"Loading cloud (step=%d, voxel=%f m) : %s", downsampleStep, voxelSize, path.c_str());
3266 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZ>);
3273 pcl::io::loadPCDFile(path, *cloud);
3277 pcl::io::loadPLYFile(path, *cloud);
3279 int previousSize = (int)cloud->size();
3280 if(downsampleStep > 1 && cloud->size())
3283 UDEBUG(
"Downsampling scan (step=%d): %d -> %d", downsampleStep, previousSize, (
int)cloud->size());
3285 previousSize = (int)cloud->size();
3286 if(voxelSize > 0.0
f && cloud->size())
3289 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())
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)
pcl::PointCloud< pcl::PointXYZRGBNormal >::Ptr RTABMAP_EXP laserScanToPointCloudRGBNormal(const LaserScan &laserScan, const Transform &transform=Transform(), unsigned char r=100, unsigned char g=100, unsigned char b=100)
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::PointXYZRGB RTABMAP_EXP laserScanToPointRGB(const LaserScan &laserScan, int index, unsigned char r=100, unsigned char g=100, unsigned char b=100)
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)
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP laserScanToPointCloudRGB(const LaserScan &laserScan, const Transform &transform=Transform(), unsigned char r=100, unsigned char g=100, unsigned char b=100)
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)
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)
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)
LaserScan RTABMAP_EXP laserScanFromPointCloud(const pcl::PCLPointCloud2 &cloud, bool filterNaNs=true, bool is2D=false, const Transform &transform=Transform())