mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Fixed assert when exporting textured mesh with both multiband and blending enabled with grayscale images
This commit is contained in:
@@ -2398,7 +2398,7 @@ bool multiBandTexturing(
|
|||||||
std::string tmpImageDirectory = outputDirectory+"/rtabmap_tmp_textures";
|
std::string tmpImageDirectory = outputDirectory+"/rtabmap_tmp_textures";
|
||||||
UDirectory::removeDir(tmpImageDirectory);
|
UDirectory::removeDir(tmpImageDirectory);
|
||||||
UDirectory::makeDir(tmpImageDirectory);
|
UDirectory::makeDir(tmpImageDirectory);
|
||||||
UINFO("Temporary saving images in directory \"%s\"...", tmpImageDirectory.c_str());
|
UINFO("Temporary saving images from %ld nodes in directory \"%s\"...", cameraPoses.size(), tmpImageDirectory.c_str());
|
||||||
int viewId = 0;
|
int viewId = 0;
|
||||||
for(std::map<int, Transform>::const_iterator iter = cameraPoses.lower_bound(1); iter!=cameraPoses.end(); ++iter)
|
for(std::map<int, Transform>::const_iterator iter = cameraPoses.lower_bound(1); iter!=cameraPoses.end(); ++iter)
|
||||||
{
|
{
|
||||||
@@ -2510,28 +2510,45 @@ bool multiBandTexturing(
|
|||||||
imageSize.height = image.rows;
|
imageSize.height = image.rows;
|
||||||
imageSize.width = image.cols;
|
imageSize.width = image.cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
UASSERT(image.cols % imageSize.width == 0);
|
UASSERT(image.cols % imageSize.width == 0);
|
||||||
cv::Mat imageRoi = image.colRange(i*imageSize.width, (i+1)*imageSize.width);
|
cv::Mat imageRoi = image.colRange(i*imageSize.width, (i+1)*imageSize.width);
|
||||||
|
|
||||||
if(gains.find(camId) != gains.end() &&
|
if(gains.find(camId) != gains.end() &&
|
||||||
gains.at(camId).find(i) != gains.at(camId).end())
|
gains.at(camId).find(i) != gains.at(camId).end())
|
||||||
{
|
{
|
||||||
const cv::Vec4d & g = gains.at(camId).at(i);
|
const cv::Vec4d & g = gains.at(camId).at(i);
|
||||||
std::vector<cv::Mat> channels;
|
if(imageRoi.channels() == 1)
|
||||||
cv::split(imageRoi, channels);
|
{
|
||||||
|
cv::multiply(imageRoi, g.val[0], imageRoi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::vector<cv::Mat> channels;
|
||||||
|
cv::split(imageRoi, channels);
|
||||||
|
|
||||||
// assuming BGR
|
// assuming BGR
|
||||||
cv::multiply(channels[0], g.val[gainRGB?3:0], channels[0]);
|
cv::multiply(channels[0], g.val[gainRGB?3:0], channels[0]);
|
||||||
cv::multiply(channels[1], g.val[gainRGB?2:0], channels[1]);
|
cv::multiply(channels[1], g.val[gainRGB?2:0], channels[1]);
|
||||||
cv::multiply(channels[2], g.val[gainRGB?1:0], channels[2]);
|
cv::multiply(channels[2], g.val[gainRGB?1:0], channels[2]);
|
||||||
|
|
||||||
cv::Mat output;
|
cv::Mat output;
|
||||||
cv::merge(channels, output);
|
cv::merge(channels, output);
|
||||||
imageRoi = output;
|
imageRoi = output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(blendingGains.find(camId) != blendingGains.end() &&
|
if(blendingGains.find(camId) != blendingGains.end() &&
|
||||||
blendingGains.at(camId).find(i) != blendingGains.at(camId).end())
|
blendingGains.at(camId).find(i) != blendingGains.at(camId).end())
|
||||||
{
|
{
|
||||||
|
// Should be color for blending options
|
||||||
|
if(imageRoi.channels() == 1)
|
||||||
|
{
|
||||||
|
cv::Mat imageRoiColor;
|
||||||
|
cv::cvtColor(imageRoi, imageRoiColor, CV_GRAY2BGR);
|
||||||
|
imageRoi = imageRoiColor;
|
||||||
|
}
|
||||||
|
|
||||||
cv::Mat g = blendingGains.at(camId).at(i);
|
cv::Mat g = blendingGains.at(camId).at(i);
|
||||||
cv::Mat dst;
|
cv::Mat dst;
|
||||||
cv::blur(g, dst, cv::Size(3,3));
|
cv::blur(g, dst, cv::Size(3,3));
|
||||||
@@ -2559,9 +2576,7 @@ bool multiBandTexturing(
|
|||||||
sfmData.intrinsics.insert(std::make_pair((IndexT)viewId, camPtr));
|
sfmData.intrinsics.insert(std::make_pair((IndexT)viewId, camPtr));
|
||||||
|
|
||||||
std::string imagePath = tmpImageDirectory+uFormat("/%d.jpg", viewId);
|
std::string imagePath = tmpImageDirectory+uFormat("/%d.jpg", viewId);
|
||||||
|
|
||||||
cv::imwrite(imagePath, imageRoi);
|
cv::imwrite(imagePath, imageRoi);
|
||||||
|
|
||||||
std::shared_ptr<sfmData::View> viewPtr = std::make_shared<sfmData::View>(
|
std::shared_ptr<sfmData::View> viewPtr = std::make_shared<sfmData::View>(
|
||||||
imagePath,
|
imagePath,
|
||||||
(IndexT)viewId,
|
(IndexT)viewId,
|
||||||
@@ -2572,8 +2587,9 @@ bool multiBandTexturing(
|
|||||||
sfmData.views.insert(std::make_pair((IndexT)viewId, viewPtr));
|
sfmData.views.insert(std::make_pair((IndexT)viewId, viewPtr));
|
||||||
++viewId;
|
++viewId;
|
||||||
}
|
}
|
||||||
|
UDEBUG("camId=%d", camId);
|
||||||
}
|
}
|
||||||
UINFO("Temporary saving images in directory \"%s\"... done (%d images). %fs", tmpImageDirectory.c_str(), viewId, (int)cameraPoses.size(), timer.ticks());
|
UINFO("Temporary saving images in directory \"%s\"... done (%d images of %d nodes). %fs", tmpImageDirectory.c_str(), viewId, (int)cameraPoses.size(), timer.ticks());
|
||||||
|
|
||||||
mvsUtils::MultiViewParams mp(sfmData);
|
mvsUtils::MultiViewParams mp(sfmData);
|
||||||
|
|
||||||
|
|||||||
@@ -4676,7 +4676,7 @@ void ExportCloudsDialog::saveTextureMeshes(
|
|||||||
path.toStdString(),
|
path.toStdString(),
|
||||||
mesh->cloud,
|
mesh->cloud,
|
||||||
mesh->tex_polygons[0],
|
mesh->tex_polygons[0],
|
||||||
poses,
|
filterNodes(poses),
|
||||||
textureVertexToPixels,
|
textureVertexToPixels,
|
||||||
images,
|
images,
|
||||||
calibrations,
|
calibrations,
|
||||||
|
|||||||
Reference in New Issue
Block a user