31 #include <Math/Math3d.h>
32 #include <Image/ByteImage.h>
33 #include <Image/ImageProcessor.h>
34 #include <Image/IplImageAdaptor.h>
35 #include <Features/SIFTFeatures/SIFTFeatureEntry.h>
36 #include <Features/SIFTFeatures/SIFTFeatureCalculator.h>
37 #include <Image/StereoMatcher.h>
38 #include <Calibration/StereoCalibration.h>
39 #include <Calibration/Calibration.h>
40 #include <Calibration/Rectification.h>
41 #include <Threading/Threading.h>
43 #include <opencv2/calib3d.hpp>
47 #include <opencv2/opencv.hpp>
63 m_pSIFTFeatureCalculator =
new CSIFTFeatureCalculator();
68 m_pInterestPoints =
new Vec2d[m_nMaxNumInterestPoints];
74 delete[] m_pInterestPoints;
78 void CFeatureCalculation::GetAllFeaturePoints(
const CByteImage* pImageLeftColor,
const CByteImage* pImageRightColor,
const CByteImage* pImageLeftGrey,
const CByteImage* pImageRightGrey,
const int nDisparityPointDistance, CStereoCalibration* pStereoCalibration,
79 CSIFTFeatureArray& aAllSIFTPoints, std::vector<CMSERDescriptor3D*>& aAllMSERs, std::vector<CHypothesisPoint*>& aPointsFromDepthImage, CByteImage* pDisparityImage, std::vector<Vec3d>* pAll3DPoints)
82 gettimeofday(&tStart, 0);
85 #pragma omp parallel sections
100 CStereoMatcher* stereoMatcher =
new CStereoMatcher();
101 stereoMatcher->InitCameraParameters(pStereoCalibration,
false);
107 CDynamicArray afSIFTDescriptors(4);
109 #pragma omp for schedule(static, 32)
111 for (
int i = 0; i < nNumFeatures; i++)
115 Vec2d vCorrespondingPointRight;
120 int nMatchingResult = stereoMatcher->Match(pImageLeftGrey, pImageRightGrey, (
int) m_pInterestPoints[i].x, (
int) m_pInterestPoints[i].y,
121 10, nDispMin, nDispMax, vCorrespondingPointRight, vPoint3D, 0.7f,
true);
123 if (nMatchingResult >= 0)
127 m_pSIFTFeatureCalculator->CreateSIFTDescriptors(pImageLeftGrey, &afSIFTDescriptors, m_pInterestPoints[i].x,
128 m_pInterestPoints[i].y, 1.0f,
false,
false);
130 if (afSIFTDescriptors.GetSize() > 0)
134 aAllSIFTPoints.AddElement((CSIFTFeatureEntry*)((CSIFTFeatureEntry*)afSIFTDescriptors[0])->Clone());
135 aAllSIFTPoints[aAllSIFTPoints.GetSize() - 1]->point3d = vPoint3D;
137 CSIFTFeatureEntry* pFeature = (CSIFTFeatureEntry*)afSIFTDescriptors[0];
138 afSIFTDescriptors[0]->bDelete =
false;
139 afSIFTDescriptors.Clear();
148 delete stereoMatcher;
181 #ifdef OLP_USE_DEPTH_MAP
186 GetPointsFromDisparity(pImageLeftColor, pImageRightColor, pImageLeftGrey, pImageRightGrey, pStereoCalibration, nDisparityPointDistance, aPointsFromDepthImage, pDisparityImage, pAll3DPoints);
199 gettimeofday(&tEnd, 0);
200 long tTimeDiff = (1000 * tEnd.tv_sec + tEnd.tv_usec / 1000) - (1000 * tStart.tv_sec + tStart.tv_usec / 1000);
201 ARMARX_VERBOSE_S <<
"Time for GetAllFeaturePoints(): " << tTimeDiff <<
" ms";
207 #ifdef OLP_USE_DEPTH_MAP
210 CSIFTFeatureArray& aAllSIFTPoints, std::vector<CMSERDescriptor3D*>& aAllMSERs, std::vector<CHypothesisPoint*>& aPointsFromDepthImage,
const CCalibration* calibration)
212 timeval tStart, tEnd;
213 gettimeofday(&tStart, 0);
214 omp_set_nested(
true);
216 #pragma omp parallel sections
231 CDynamicArray afSIFTDescriptors(4);
233 #pragma omp for schedule(static, 32)
234 for (
int i = 0; i < nNumFeatures; i++)
238 Vec3d point3D = GetCorresponding3DPoint(m_pInterestPoints[i], pointcloud);
244 m_pSIFTFeatureCalculator->CreateSIFTDescriptors(pImageLeftGrey, &afSIFTDescriptors, m_pInterestPoints[i].x,
245 m_pInterestPoints[i].y, 1.0f,
false,
false);
247 if (afSIFTDescriptors.GetSize() > 0)
251 aAllSIFTPoints.AddElement((CSIFTFeatureEntry*)((CSIFTFeatureEntry*)afSIFTDescriptors[0])->Clone());
252 aAllSIFTPoints[aAllSIFTPoints.GetSize() - 1]->point3d.x = point3D.x;
253 aAllSIFTPoints[aAllSIFTPoints.GetSize() - 1]->point3d.y = point3D.y;
254 aAllSIFTPoints[aAllSIFTPoints.GetSize() - 1]->point3d.z = point3D.z;
256 CSIFTFeatureEntry* pFeature = (CSIFTFeatureEntry*)afSIFTDescriptors[0];
257 afSIFTDescriptors[0]->bDelete =
false;
258 afSIFTDescriptors.Clear();
279 CByteImage* pHSVImageLeft =
new CByteImage(pImageLeftColor);
280 ImageProcessor::CalculateHSVImage(pImageLeftColor, pHSVImageLeft);
282 std::vector<CMSERDescriptor*> aMSERDescriptors2D;
285 for (
size_t i = 0; i < aMSERDescriptors2D.size(); i++)
292 descriptor3D->
vPosition = GetCorresponding3DPoint(mean2D, pointcloud);
294 Vec2d vSigmaPoint2D, vTemp;
297 Math2d::AddVecVec(mean2D, vTemp, vSigmaPoint2D);
298 descriptor3D->
vSigmaPoint1a = GetCorresponding3DPoint(vSigmaPoint2D, pointcloud);
301 Math2d::AddVecVec(mean2D, vTemp, vSigmaPoint2D);
302 descriptor3D->
vSigmaPoint1b = GetCorresponding3DPoint(vSigmaPoint2D, pointcloud);
305 Math2d::AddVecVec(mean2D, vTemp, vSigmaPoint2D);
306 descriptor3D->
vSigmaPoint2a = GetCorresponding3DPoint(vSigmaPoint2D, pointcloud);
309 Math2d::AddVecVec(mean2D, vTemp, vSigmaPoint2D);
310 descriptor3D->
vSigmaPoint2b = GetCorresponding3DPoint(vSigmaPoint2D, pointcloud);
312 aAllMSERs.push_back(descriptor3D);
326 const float fIntensityFactor = 1.0f / 255.0f;
327 const size_t width = pointcloud->width;
328 const size_t height = pointcloud->height;
330 CByteImage* leftImageGaussFiltered =
new CByteImage(pImageLeftColor);
331 ::ImageProcessor::GaussianSmooth3x3(pImageLeftColor, leftImageGaussFiltered);
333 for (
size_t i = 0; i < height; i += nDisparityPointDistance)
335 for (
size_t j = 0; j < width; j += nDisparityPointDistance)
337 const pcl::PointXYZRGBA point3D = pointcloud->at(i * width + j);
346 Vec3d vPoint3D = {point3D.x, point3D.y, point3D.z};
347 Math3d::SetVec(pNewPoint->
vPosition, vPoint3D);
354 calibration->CameraToImageCoordinates(vPoint3D, vPoint2D,
false);
355 int u = (int)(vPoint2D.x + 0.5f);
356 int v = (int)(vPoint2D.y + 0.5f);
357 u = (u < 0) ? 0 : ((u > leftImageGaussFiltered->width - 1) ? leftImageGaussFiltered->width - 1 : u);
358 v = (
v < 0) ? 0 : ((
v > leftImageGaussFiltered->height - 1) ? leftImageGaussFiltered->height - 1 :
v);
360 const float weight = 1.0f;
361 r = weight * leftImageGaussFiltered->pixels[3 * (
v * leftImageGaussFiltered->width + u)] + (1.0f - weight) * point3D.r;
362 g = weight * leftImageGaussFiltered->pixels[3 * (
v * leftImageGaussFiltered->width + u) + 1] + (1.0f - weight) * point3D.g;
363 b = weight * leftImageGaussFiltered->pixels[3 * (
v * leftImageGaussFiltered->width + u) + 2] + (1.0f - weight) * point3D.b;
365 const float fIntensity = (r + g + b) / 3.0f;
366 const float normalizationFactor = 1.0f / (fIntensity + 3.0f);
367 pNewPoint->
fIntensity = fIntensity * fIntensityFactor;
368 pNewPoint->
fColorR = normalizationFactor * (r + 1);
369 pNewPoint->
fColorG = normalizationFactor * (g + 1);
370 pNewPoint->
fColorB = normalizationFactor * (b + 1);
372 aPointsFromDepthImage.push_back(pNewPoint);
378 delete leftImageGaussFiltered;
383 gettimeofday(&tEnd, 0);
384 long tTimeDiff = (1000 * tEnd.tv_sec + tEnd.tv_usec / 1000) - (1000 * tStart.tv_sec + tStart.tv_usec / 1000);
385 ARMARX_VERBOSE_S <<
"Time for GetAllFeaturePoints(): " << tTimeDiff <<
" ms";
391 static void doStereoSGBM(
int minDisparity,
int numDisparities,
int nSADWindowSize,
int P1,
int P2,
int disp12MaxDiff,
392 cv::Mat leftInput, cv::Mat rightInput, cv::Mat output)
394 int preFilterCap = 0;
395 int uniquenessRatio = 0;
396 int speckleWindowSize = 0;
397 int speckleRange = 0;
398 #if CV_MAJOR_VERSION == 2
400 cv::StereoSGBM stereoSGBM(minDisparity, numDisparities, nSADWindowSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize, speckleRange, fullDP);
401 stereoSGBM(leftInput, rightInput, output);
403 cv::Ptr<cv::StereoSGBM> stereoSGBM = cv::StereoSGBM::create(minDisparity, numDisparities, nSADWindowSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize, speckleRange, cv::StereoSGBM::MODE_SGBM);
404 stereoSGBM->compute(leftInput, rightInput, output);
410 void CFeatureCalculation::GetPointsFromDisparity(
const CByteImage* pImageLeftColor,
const CByteImage* pImageRightColor,
const CByteImage* pImageLeftGrey,
const CByteImage* pImageRightGrey, CStereoCalibration* pStereoCalibration,
411 const int nDisparityPointDistance, std::vector<CHypothesisPoint*>& aPointsFromDisparity, CByteImage* pDisparityImage, std::vector<Vec3d>* pAll3DPoints)
414 CByteImage* pRectifiedImageLeftGrey, *pRectifiedImageRightGrey, *pRectifiedImageLeftGreyHalfsize, *pRectifiedImageRightGreyHalfsize, *pRectifiedImageLeftGreyQuartersize, *pRectifiedImageRightGreyQuartersize;
415 IplImage* pRectifiedIplImageLeft, *pRectifiedIplImageRight, *pRectifiedIplImageLeftHalfsize, *pRectifiedIplImageRightHalfsize, *pRectifiedIplImageLeftQuartersize, *pRectifiedIplImageRightQuartersize;
416 CByteImage* pRectifiedImageLeftColorGaussFiltered;
417 cv::Mat mDispImg, mDispImgHalfsize, mDispImgQuartersize;
418 bool bGreyImagesReady =
false;
419 bool bGreyImagesHalfsizeReady =
false;
420 bool bGreyImagesQuartersizeReady =
false;
422 #pragma omp parallel sections
426 const CByteImage* ppOriginalImages[2];
427 ppOriginalImages[0] = pImageLeftGrey;
428 ppOriginalImages[1] = pImageRightGrey;
431 CByteImage* ppRectifiedImages[2];
432 ppRectifiedImages[0] = pRectifiedImageLeftGrey;
433 ppRectifiedImages[1] = pRectifiedImageRightGrey;
435 CRectification* pRectification =
new CRectification(
true,
false);
436 pRectification->Init(pStereoCalibration);
437 pRectification->Rectify(ppOriginalImages, ppRectifiedImages);
439 pRectifiedIplImageLeft = IplImageAdaptor::Adapt(pRectifiedImageLeftGrey);
440 pRectifiedIplImageRight = IplImageAdaptor::Adapt(pRectifiedImageRightGrey);
441 bGreyImagesReady =
true;
446 ImageProcessor::Resize(pRectifiedImageLeftGrey, pRectifiedImageLeftGreyHalfsize);
447 ImageProcessor::Resize(pRectifiedImageRightGrey, pRectifiedImageRightGreyHalfsize);
449 pRectifiedIplImageLeftHalfsize = IplImageAdaptor::Adapt(pRectifiedImageLeftGreyHalfsize);
450 pRectifiedIplImageRightHalfsize = IplImageAdaptor::Adapt(pRectifiedImageRightGreyHalfsize);
451 bGreyImagesHalfsizeReady =
true;
456 ImageProcessor::Resize(pRectifiedImageLeftGrey, pRectifiedImageLeftGreyQuartersize);
457 ImageProcessor::Resize(pRectifiedImageRightGrey, pRectifiedImageRightGreyQuartersize);
459 pRectifiedIplImageLeftQuartersize = IplImageAdaptor::Adapt(pRectifiedImageLeftGreyQuartersize);
460 pRectifiedIplImageRightQuartersize = IplImageAdaptor::Adapt(pRectifiedImageRightGreyQuartersize);
461 bGreyImagesQuartersizeReady =
true;
463 delete pRectification;
468 const CByteImage* ppOriginalImages[2];
469 ppOriginalImages[0] = pImageLeftColor;
470 ppOriginalImages[1] = pImageRightColor;
473 CByteImage* ppRectifiedImages[2];
474 ppRectifiedImages[0] = pRectifiedImageLeftColor;
475 ppRectifiedImages[1] = pRectifiedImageRightColor;
477 CRectification* pRectification =
new CRectification(
true,
false);
478 pRectification->Init(pStereoCalibration);
479 pRectification->Rectify(ppOriginalImages, ppRectifiedImages);
482 ImageProcessor::GaussianSmooth3x3(pRectifiedImageLeftColor, pRectifiedImageLeftColorGaussFiltered);
484 delete pRectifiedImageLeftColor;
485 delete pRectifiedImageRightColor;
486 delete pRectification;
494 while (!bGreyImagesReady)
496 Threading::YieldThread();
513 const cv::Mat mLeftImg = cv::cvarrToMat(pRectifiedIplImageLeft);
514 const cv::Mat mRightImg = cv::cvarrToMat(pRectifiedIplImageRight);
515 const int nSADWindowSize = 7;
516 const int nPenaltyDispDiffOne = 8 * 3 * nSADWindowSize * nSADWindowSize;
517 const int nPenaltyDispDiffBiggerOne = 32 * 3 * nSADWindowSize * nSADWindowSize;
519 doStereoSGBM(1, 8 * 16, nSADWindowSize, nPenaltyDispDiffOne, nPenaltyDispDiffBiggerOne, 4, mLeftImg, mRightImg, mDispImg);
525 while (!bGreyImagesHalfsizeReady)
527 Threading::YieldThread();
530 const cv::Mat mLeftImg = cv::cvarrToMat(pRectifiedIplImageLeftHalfsize);
531 const cv::Mat mRightImg = cv::cvarrToMat(pRectifiedIplImageRightHalfsize);
532 const int nSADWindowSize = 7;
533 const int nPenaltyDispDiffOne = 8 * 3 * nSADWindowSize * nSADWindowSize;
534 const int nPenaltyDispDiffBiggerOne = 32 * 3 * nSADWindowSize * nSADWindowSize;
536 doStereoSGBM(1, 4 * 16, nSADWindowSize, nPenaltyDispDiffOne, nPenaltyDispDiffBiggerOne, 4, mLeftImg, mRightImg, mDispImg);
542 while (!bGreyImagesQuartersizeReady)
544 Threading::YieldThread();
547 const cv::Mat mLeftImg = cv::cvarrToMat(pRectifiedIplImageLeftQuartersize);
548 const cv::Mat mRightImg = cv::cvarrToMat(pRectifiedIplImageRightQuartersize);
549 const int nSADWindowSize = 7;
550 const int nPenaltyDispDiffOne = 8 * 3 * nSADWindowSize * nSADWindowSize;
551 const int nPenaltyDispDiffBiggerOne = 32 * 3 * nSADWindowSize * nSADWindowSize;
553 doStereoSGBM(1, 4 * 16, nSADWindowSize, nPenaltyDispDiffOne, nPenaltyDispDiffBiggerOne, 4, mLeftImg, mRightImg, mDispImg);
558 CStereoMatcher* pStereoMatcher =
new CStereoMatcher();
559 CStereoCalibration* pStereoCalibrationCopy =
new CStereoCalibration(*pStereoCalibration);
560 pStereoMatcher->InitCameraParameters(pStereoCalibrationCopy,
false);
561 const int nDispMin = pStereoMatcher->GetDisparityEstimate(4000);
562 const int nDispMax = pStereoMatcher->GetDisparityEstimate(200);
563 Vec2d vImgPointLeft, vImgPointRight;
565 const float fIntensityFactor = 1.0f / (3 * 255);
570 #pragma omp parallel for schedule(static, 80)
575 int nDispFullsize = mDispImg.at<
short>(i, j) / 16;
576 int nDispHalfsize = 2 * mDispImgHalfsize.at<
short>(i / 2, j / 2) / 16;
577 int nDispQuartersize = 4 * mDispImgQuartersize.at<
short>(i / 4, j / 4) / 16;
581 int nNumValidDisparities = 0;
583 if ((nDispFullsize > nDispMin) && (nDispFullsize < nDispMax))
585 nDisp += nDispFullsize;
586 nNumValidDisparities++;
589 if ((nDispHalfsize > nDispMin) && (nDispHalfsize < nDispMax))
591 nDisp += nDispHalfsize;
592 nNumValidDisparities++;
595 if ((nDispQuartersize > nDispMin) && (nDispQuartersize < nDispMax))
597 nDisp += nDispQuartersize;
598 nNumValidDisparities++;
601 if (nNumValidDisparities > 0)
603 fDisp = (
float)nDisp / (
float)nNumValidDisparities;
618 pDisparitiesCopy[i] = pDisparities[i];
621 const int nMargin = 10;
622 const int nHoleFillingAveragingRadius = 5;
631 int nNumValidDisparities = 0;
633 for (
int k = -nHoleFillingAveragingRadius; k <= nHoleFillingAveragingRadius; k++)
635 for (
int l = -nHoleFillingAveragingRadius; l <= nHoleFillingAveragingRadius; l++)
640 nNumValidDisparities++;
645 if (nNumValidDisparities > 0)
647 pDisparities[i *
OLP_IMG_WIDTH + j] = nSum / nNumValidDisparities;
663 pRectifiedDisparityImage->pixels[i *
OLP_IMG_WIDTH + j] = (nDisp > 255) ? 255 : nDisp;
668 ImageProcessor::Zero(pDisparityImage);
669 Vec2d vRectPos, vUnRectPos;
670 Mat3d mRectificationHomography = pStereoCalibration->rectificationHomographyLeft;
678 Math2d::ApplyHomography(mRectificationHomography, vRectPos, vUnRectPos);
682 pDisparityImage->pixels[(int)vUnRectPos.y *
OLP_IMG_WIDTH + (
int)vUnRectPos.x] = pRectifiedDisparityImage->pixels[i *
OLP_IMG_WIDTH + j];
689 delete pRectifiedDisparityImage;
702 #pragma omp parallel sections
706 CalculateSmoothedDisparityImage(pDisparities, pSmoothedDisparity1, 0);
711 CalculateSmoothedDisparityImage(pDisparities, pSmoothedDisparity2, 1);
716 CalculateSmoothedDisparityImage(pDisparities, pSmoothedDisparity3, 2);
721 CalculateSmoothedDisparityImage(pDisparities, pSmoothedDisparity4, 4);
727 pSmoothedDisparity[i] = 0.25f * (pSmoothedDisparity1[i] + pSmoothedDisparity2[i] + pSmoothedDisparity3[i] + pSmoothedDisparity4[i]);
730 delete[] pSmoothedDisparity1;
731 delete[] pSmoothedDisparity2;
732 delete[] pSmoothedDisparity3;
733 delete[] pSmoothedDisparity4;
739 pSmoothedDisparity[i] = pDisparities[i];
744 const float fDispMin = nDispMin;
745 const float fDispMax = nDispMax;
746 CDynamicArray afSIFTDescriptors(4);
750 for (
int j = 0; j <
OLP_IMG_WIDTH; j += nDisparityPointDistance)
755 if ((fDisp > fDispMin) && (fDisp < fDispMax))
760 vImgPointRight.x = j - fDisp;
761 vImgPointRight.y = i;
763 pStereoCalibration->Calculate3DPoint(vImgPointLeft, vImgPointRight, vPoint3D,
true,
false);
771 Math3d::SetVec(pNewPoint->
vPosition, vPoint3D);
776 const float fIntensity = pRectifiedImageLeftColorGaussFiltered->pixels[3 * (i *
OLP_IMG_WIDTH + j)] + pRectifiedImageLeftColorGaussFiltered->pixels[3 * (i *
OLP_IMG_WIDTH + j) + 1] + pRectifiedImageLeftColorGaussFiltered->pixels[3 * (i *
OLP_IMG_WIDTH + j) + 2] + 3;
777 pNewPoint->
fIntensity = (fIntensity - 3) * fIntensityFactor;
778 pNewPoint->
fColorR = (pRectifiedImageLeftColorGaussFiltered->pixels[3 * (i *
OLP_IMG_WIDTH + j)] + 1) / fIntensity;
779 pNewPoint->
fColorG = (pRectifiedImageLeftColorGaussFiltered->pixels[3 * (i *
OLP_IMG_WIDTH + j) + 1] + 1) / fIntensity;
780 pNewPoint->
fColorB = (pRectifiedImageLeftColorGaussFiltered->pixels[3 * (i *
OLP_IMG_WIDTH + j) + 2] + 1) / fIntensity;
783 m_pSIFTFeatureCalculator->CreateSIFTDescriptors(pRectifiedImageLeftGrey, &afSIFTDescriptors, j, i, 1.0f,
false,
false);
785 if (afSIFTDescriptors.GetSize() > 0)
787 pNewPoint->
pFeatureDescriptors->AddElement((CSIFTFeatureEntry*)((CSIFTFeatureEntry*)afSIFTDescriptors[0])->Clone());
790 CSIFTFeatureEntry* pFeature = (CSIFTFeatureEntry*)afSIFTDescriptors[0];
791 afSIFTDescriptors[0]->bDelete =
false;
792 afSIFTDescriptors.Clear();
796 aPointsFromDisparity.push_back(pNewPoint);
810 for (
int j = 0; j <
OLP_IMG_WIDTH; j += nDisparityPointDistance)
815 vImgPointRight.x = j - fDisp;
816 vImgPointRight.y = i;
817 pStereoCalibration->Calculate3DPoint(vImgPointLeft, vImgPointRight, vPoint3D,
true,
false);
821 if (aPointsFromDisparity.size() > 0)
823 Math3d::SetVec(vPoint3D, aPointsFromDisparity.at(0)->vPosition);
827 pAll3DPoints->push_back(vPoint3D);
833 delete pRectifiedImageLeftGrey;
834 delete pRectifiedImageRightGrey;
835 delete pRectifiedImageLeftGreyHalfsize;
836 delete pRectifiedImageRightGreyHalfsize;
837 delete pRectifiedImageLeftGreyQuartersize;
838 delete pRectifiedImageRightGreyQuartersize;
839 delete pRectifiedImageLeftColorGaussFiltered;
840 delete pStereoMatcher;
841 delete pStereoCalibrationCopy;
842 cvReleaseImageHeader(&pRectifiedIplImageLeft);
843 cvReleaseImageHeader(&pRectifiedIplImageRight);
844 delete[] pSmoothedDisparity;
850 void CFeatureCalculation::CalculateSmoothedDisparityImage(
float* pInputDisparity,
float* pSmoothedDisparity,
const int nRadius)
854 pSmoothedDisparity[i] = pInputDisparity[i];
863 if (pInputDisparity[nIndex] != 0)
868 for (
int l = -nRadius; l <= nRadius; l++)
870 for (
int k = -nRadius; k <= nRadius; k++)
874 if (pInputDisparity[nTempIndex] != 0)
876 fSum += pInputDisparity[nTempIndex];
882 pSmoothedDisparity[nIndex] = fSum / (
float)nNumPixels;
890 Vec3d CFeatureCalculation::GetCorresponding3DPoint(
const Vec2d point2D,
const pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pointcloud)
893 const int width = pointcloud->width;
894 const int height = pointcloud->height;
895 const int x = (point2D.x < 0) ? 0 : ((point2D.x > width - 1) ? width - 1 : point2D.x);
896 const int y = (point2D.y < 0) ? 0 : ((point2D.y > height - 1) ? height - 1 : point2D.y);
897 const int index = y * width + x;
898 pcl::PointXYZRGBA point3D = pointcloud->at(
index);
899 result.x = point3D.x;
900 result.y = point3D.y;
901 result.z = point3D.z;