Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSensorSize update #1519

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading