Skip to content

Commit

Permalink
Merge pull request #1519 from alicevision/bugfix/getSensorSize
Browse files Browse the repository at this point in the history
getSensorSize update
  • Loading branch information
mugulmd authored Aug 28, 2023
2 parents 9c9b2d1 + 5ed01b4 commit f21852d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/aliceVision/sfmData/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ int View::getSensorSize(const std::vector<sensorDB::Datasheet>& sensorDatabase,
const std::string& model = getMetadataModel();
focalLengthmm = getMetadataFocalLength();
const bool hasCameraMetadata = (!make.empty() || !model.empty());
const double imageRatio = static_cast<double>(getWidth()) / static_cast<double>(getHeight());

if (hasCameraMetadata)
{
Expand Down Expand Up @@ -258,7 +259,6 @@ int View::getSensorSize(const std::vector<sensorDB::Datasheet>& sensorDatabase,
const bool hasFocalIn35mmMetadata = hasDigitMetadata({"Exif:FocalLengthIn35mmFilm", "FocalLengthIn35mmFilm"});
if (hasFocalIn35mmMetadata)
{
const double imageRatio = static_cast<double>(getWidth()) / static_cast<double>(getHeight());
const double diag24x36 = std::sqrt(36.0 * 36.0 + 24.0 * 24.0);
const double focalIn35mm = hasFocalIn35mmMetadata ? getDoubleMetadata({"Exif:FocalLengthIn35mmFilm", "FocalLengthIn35mmFilm"}) : -1.0;

Expand Down Expand Up @@ -293,8 +293,6 @@ int View::getSensorSize(const std::vector<sensorDB::Datasheet>& sensorDatabase,
ALICEVISION_LOG_DEBUG(ss.str());
}

sensorHeight = (imageRatio > 1.0) ? sensorWidth / imageRatio : sensorWidth * imageRatio;

intrinsicInitMode = camera::EInitMode::ESTIMATED;
}
else if (sensorWidth > 0 && focalLengthmm <= 0)
Expand Down Expand Up @@ -372,6 +370,10 @@ int View::getSensorSize(const std::vector<sensorDB::Datasheet>& sensorDatabase,
sensorWidth = 36.0;
sensorHeight = 24.0;
}
else
{
sensorHeight = (imageRatio > 1.0) ? sensorWidth / imageRatio : sensorWidth * imageRatio;
}

return errCode;
}
Expand Down

0 comments on commit f21852d

Please sign in to comment.