util3d::mergeTextures() added interface with single calibrations for convenience

This commit is contained in:
matlabbe
2018-04-09 12:26:09 -04:00
parent d9716590b1
commit cd125ae274
2 changed files with 66 additions and 4 deletions

View File

@@ -194,6 +194,24 @@ pcl::PolygonMesh::Ptr RTABMAP_EXP assemblePolygonMesh(
* Merge all textures in the mesh into "textureCount" textures of size "textureSize".
* @return merged textures corresponding to new materials set in TextureMesh (height=textureSize, width=textureSize*materials)
*/
cv::Mat RTABMAP_EXP mergeTextures(
pcl::TextureMesh & mesh,
const std::map<int, cv::Mat> & images, // raw or compressed, can be empty if memory or dbDriver should be used
const std::map<int, CameraModel> & calibrations, // Should match images
const Memory * memory = 0, // Should be set if images are not set
const DBDriver * dbDriver = 0, // Should be set if images and memory are not set
int textureSize = 4096,
int textureCount = 1,
const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels = std::vector<std::map<int, pcl::PointXY> >(), // needed for parameters below
bool gainCompensation = true,
float gainBeta = 10.0f,
bool gainRGB = true, //Do gain compensation on each channel
bool blending = true,
int blendingDecimation = 0, //0=auto depending on projected polygon size and texture size
int brightnessContrastRatioLow = 0, //0=disabled, values between 0 and 100
int brightnessContrastRatioHigh = 0, //0=disabled, values between 0 and 100
bool exposureFusion = false, //Exposure fusion can be used only with OpenCV3
const ProgressState * state = 0);
cv::Mat RTABMAP_EXP mergeTextures(
pcl::TextureMesh & mesh,
const std::map<int, cv::Mat> & images, // raw or compressed, can be empty if memory or dbDriver should be used

View File

@@ -640,10 +640,10 @@ pcl::texture_mapping::CameraVector createTextureCameras(
cam.depth = cv::Mat(depthIter->second, cv::Range(0, depthIter->second.rows), cv::Range(subWidth*i, subWidth*(i+1)));
}
UWARN("%f", cam.focal_length);
UWARN("%f", cam.height);
UWARN("%f", cam.width);
UWARN("cam.pose=%s", t.prettyPrint().c_str());
UDEBUG("%f", cam.focal_length);
UDEBUG("%f", cam.height);
UDEBUG("%f", cam.width);
UDEBUG("cam.pose=%s", t.prettyPrint().c_str());
cameras.push_back(cam);
}
@@ -1362,6 +1362,50 @@ double sqr(uchar v)
return double(v)*double(v);
}
cv::Mat mergeTextures(
pcl::TextureMesh & mesh,
const std::map<int, cv::Mat> & images,
const std::map<int, CameraModel> & calibrations,
const Memory * memory,
const DBDriver * dbDriver,
int textureSize,
int textureCount,
const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels,
bool gainCompensation,
float gainBeta,
bool gainRGB,
bool blending,
int blendingDecimation,
int brightnessContrastRatioLow,
int brightnessContrastRatioHigh,
bool exposureFusion,
const ProgressState * state)
{
std::map<int, std::vector<CameraModel> > calibVectors;
for(std::map<int, CameraModel>::const_iterator iter=calibrations.begin(); iter!=calibrations.end(); ++iter)
{
std::vector<CameraModel> m;
m.push_back(iter->second);
calibVectors.insert(std::make_pair(iter->first, m));
}
return mergeTextures(mesh,
images,
calibVectors,
memory,
dbDriver,
textureSize,
textureCount,
vertexToPixels,
gainCompensation,
gainBeta,
gainRGB,
blending,
blendingDecimation,
brightnessContrastRatioLow,
brightnessContrastRatioHigh,
exposureFusion,
state);
}
cv::Mat mergeTextures(
pcl::TextureMesh & mesh,
const std::map<int, cv::Mat> & images,