Registration: added warning when GuessFlowSize is set and multi-camera is detected instead of crashing on an assert

This commit is contained in:
matlabbe
2016-06-15 18:13:11 -04:00
parent 7f55e2c9bb
commit 798c3cb373
+15 -4
View File
@@ -622,12 +622,12 @@ Transform RegistrationVis::computeTransformationImpl(
if(descriptorsFrom.rows > 0 && descriptorsTo.rows > 0) if(descriptorsFrom.rows > 0 && descriptorsTo.rows > 0)
{ {
cv::Size imageSize = imageTo.size(); cv::Size imageSize = imageTo.size();
bool isCalibrated = false; bool isCalibrated = false; // multiple cameras not supported.
if(imageSize.height == 0 || imageSize.width == 0) if(imageSize.height == 0 || imageSize.width == 0)
{ {
imageSize = fromSignature.sensorData().cameraModels().size()?fromSignature.sensorData().cameraModels()[0].imageSize():fromSignature.sensorData().stereoCameraModel().left().imageSize(); imageSize = fromSignature.sensorData().cameraModels().size() == 1?fromSignature.sensorData().cameraModels()[0].imageSize():fromSignature.sensorData().stereoCameraModel().left().imageSize();
} }
isCalibrated = imageSize.height != 0 && imageSize.width != 0 && fromSignature.sensorData().cameraModels().size()?fromSignature.sensorData().cameraModels()[0].isValidForProjection():fromSignature.sensorData().stereoCameraModel().isValidForProjection(); isCalibrated = imageSize.height != 0 && imageSize.width != 0 && fromSignature.sensorData().cameraModels().size()==1?fromSignature.sensorData().cameraModels()[0].isValidForProjection():fromSignature.sensorData().stereoCameraModel().isValidForProjection();
// If guess is set, limit the search of matches using optical flow window size // If guess is set, limit the search of matches using optical flow window size
bool guessSet = !guess.isIdentity() && !guess.isNull(); bool guessSet = !guess.isIdentity() && !guess.isNull();
@@ -641,8 +641,9 @@ Transform RegistrationVis::computeTransformationImpl(
// Use guess to project 3D "from" keypoints into "to" image // Use guess to project 3D "from" keypoints into "to" image
if(fromSignature.sensorData().cameraModels().size() > 1) if(fromSignature.sensorData().cameraModels().size() > 1)
{ {
UFATAL("Radius feature matching is not supported for multiple cameras."); UFATAL("Guess reprojection feature matching is not supported for multiple cameras.");
} }
Transform localTransform = fromSignature.sensorData().cameraModels().size()?fromSignature.sensorData().cameraModels()[0].localTransform():fromSignature.sensorData().stereoCameraModel().left().localTransform(); Transform localTransform = fromSignature.sensorData().cameraModels().size()?fromSignature.sensorData().cameraModels()[0].localTransform():fromSignature.sensorData().stereoCameraModel().left().localTransform();
Transform guessCameraRef = (guess * localTransform).inverse(); Transform guessCameraRef = (guess * localTransform).inverse();
cv::Mat R = (cv::Mat_<double>(3,3) << cv::Mat R = (cv::Mat_<double>(3,3) <<
@@ -846,11 +847,21 @@ Transform RegistrationVis::computeTransformationImpl(
else else
{ {
if(guessSet && _guessWinSize > 0 && kptsFrom3D.size() && !isCalibrated) if(guessSet && _guessWinSize > 0 && kptsFrom3D.size() && !isCalibrated)
{
if(fromSignature.sensorData().cameraModels().size() > 1 || toSignature.sensorData().cameraModels().size() > 1)
{
UWARN("Finding correspondences with the guess cannot "
"be done with multiple cameras, global matching is "
"done instead. Please set \"%s\" to 0 to avoid this warning.",
Parameters::kVisCorGuessWinSize().c_str());
}
else
{ {
UWARN("Calibration not found! Finding correspondences " UWARN("Calibration not found! Finding correspondences "
"with the guess cannot be done, global matching is " "with the guess cannot be done, global matching is "
"done instead."); "done instead.");
} }
}
UDEBUG(""); UDEBUG("");
// match between all descriptors // match between all descriptors