Skip to content

Commit

Permalink
Removed native focal length.
Browse files Browse the repository at this point in the history
Will re-add it if needed later.
  • Loading branch information
zlogic committed May 19, 2024
1 parent 60562eb commit b818e30
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions src/reconstruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const TIFFTAG_META_QUANTA: exif::Tag = exif::Tag(exif::Context::Tiff, 34682);
struct SourceImage {
img: GrayImage,
scale: (f32, f32),
focal_length_native: Option<f64>,
focal_length_35mm: Option<u32>,
tilt_angle: Option<f32>,
filename: String,
Expand All @@ -34,7 +33,6 @@ struct ImageMeta {
scale: (f32, f32),
tilt_angle: Option<f32>,
databar_height: u32,
focal_length_native: Option<f64>,
focal_length_35mm: Option<u32>,
}

Expand All @@ -47,7 +45,6 @@ impl SourceImage {
Ok(SourceImage {
img: img.to_image(),
scale: metadata.scale,
focal_length_native: metadata.focal_length_native,
focal_length_35mm: metadata.focal_length_35mm,
tilt_angle: metadata.tilt_angle,
filename: path.to_string(),
Expand All @@ -67,7 +64,6 @@ impl SourceImage {
scale: (1.0, 1.0),
tilt_angle: None,
databar_height: 0,
focal_length_native: None,
focal_length_35mm: None,
};
match SourceImage::get_metadata_exif(path) {
Expand All @@ -92,7 +88,6 @@ impl SourceImage {
scale: (1.0, 1.0),
tilt_angle: None,
databar_height: 0,
focal_length_native: None,
focal_length_35mm: None,
};
let sem_metadata = if let Some(metadata) = sem_metadata {
Expand Down Expand Up @@ -144,40 +139,6 @@ impl SourceImage {
{
result_metadata.focal_length_35mm = focal_length.value.get_uint(0);
}
if let Some(focal_length) = exif.get_field(exif::Tag::FocalLength, exif::In::PRIMARY) {
let value = match focal_length.value {
exif::Value::Rational(ref vec) => {
if !vec.is_empty() {
Some(vec[0].to_f64())
} else {
None
}
}
exif::Value::SRational(ref vec) => {
if !vec.is_empty() {
Some(vec[0].to_f64())
} else {
None
}
}
exif::Value::Float(ref vec) => {
if !vec.is_empty() {
Some(vec[0] as f64)
} else {
None
}
}
exif::Value::Double(ref vec) => {
if !vec.is_empty() {
Some(vec[0])
} else {
None
}
}
_ => None,
};
result_metadata.focal_length_native = value;
}
Ok(result_metadata)
}

Expand All @@ -202,20 +163,13 @@ impl SourceImage {
fn calibration_matrix(&self, focal_length_35mm: Option<u32>) -> Matrix3<f64> {
// Scale focal length: f_img/f_35mm == diagonal / diagonal(24mm x 36mm) (because 35mm equivalent is based on diagonal length)
let diagonal_35mm = (24.0f64 * 24.0 + 36.0 * 36.0).sqrt();
//let ratio_35mm = 36.0 / 24.0;
let width = self.img.width() as f64;
let height = self.img.height() as f64;
//let (width, height) = (width.max(height), width.min(height));
//let width = height * ratio_35mm;

let diagonal = (width * width + height * height).sqrt();
let focal_length = focal_length_35mm.or(self.focal_length_35mm).unwrap_or(1) as f64
* diagonal
/ diagonal_35mm;

//let max_width = self.img.width().max(self.img.height()) as f64;
//let focal_length = focal_length_35mm.or(self.focal_length_35mm).unwrap_or(1) as f64 / 36.0 * max_width;

Matrix3::new(
focal_length,
0.0,
Expand Down

0 comments on commit b818e30

Please sign in to comment.