cloudFromDisparity(): adjusting decimation if not valid with current image size. Standalone: ask user to set other parameters to default if some were set on command line.

This commit is contained in:
matlabbe
2017-04-28 11:43:27 -04:00
parent 1ea94c0356
commit 14baca125d
4 changed files with 58 additions and 6 deletions

View File

@@ -595,10 +595,26 @@ pcl::PointCloud<pcl::PointXYZ>::Ptr cloudFromDisparity(
std::vector<int> * validIndices)
{
UASSERT(imageDisparity.type() == CV_32FC1 || imageDisparity.type()==CV_16SC1);
UASSERT(imageDisparity.rows % decimation == 0);
UASSERT(imageDisparity.cols % decimation == 0);
UASSERT(decimation >= 1);
if(imageDisparity.rows % decimation != 0 || imageDisparity.cols % decimation != 0)
{
int oldDecimation = decimation;
while(decimation >= 1)
{
if(imageDisparity.rows % decimation == 0 && imageDisparity.cols % decimation == 0)
{
break;
}
--decimation;
}
if(imageDisparity.rows % oldDecimation != 0 || imageDisparity.cols % oldDecimation != 0)
{
UWARN("Decimation (%d) is not valid for current image size (depth=%dx%d). Highest compatible decimation used=%d.", oldDecimation, imageDisparity.cols, imageDisparity.rows, decimation);
}
}
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
//cloud.header = cameraInfo.header;
@@ -686,7 +702,24 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudFromDisparityRGB(
(imageDisparity.type() == CV_32FC1 || imageDisparity.type()==CV_16SC1));
UASSERT(imageRgb.channels() == 3 || imageRgb.channels() == 1);
UASSERT(decimation >= 1);
UASSERT(imageDisparity.rows % decimation == 0 && imageDisparity.cols % decimation == 0);
if(imageDisparity.rows % decimation != 0 || imageDisparity.cols % decimation != 0)
{
int oldDecimation = decimation;
while(decimation >= 1)
{
if(imageDisparity.rows % decimation == 0 && imageDisparity.cols % decimation == 0)
{
break;
}
--decimation;
}
if(imageDisparity.rows % oldDecimation != 0 || imageDisparity.cols % oldDecimation != 0)
{
UWARN("Decimation (%d) is not valid for current image size (depth=%dx%d). Highest compatible decimation used=%d.", oldDecimation, imageDisparity.cols, imageDisparity.rows, decimation);
}
}
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);