MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
extract_focal_length.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#include <vector>
11#include <utility>
12
13#include "sfm/camera_database.h"
15
17
18std::pair<float, FocalLengthMethod>
20{
21 /* Step 1: Check for focal length info in EXIF and database entry. */
22 float focal_length = exif.focal_length;
23 std::string camera_maker = exif.camera_maker;
24 std::string camera_model = exif.camera_model;
25 float sensor_size = -1.0f;
26 if (focal_length > 0.0f && !camera_model.empty())
27 {
28 CameraDatabase const* db = CameraDatabase::get();
29 CameraModel const* model = db->lookup(camera_maker, camera_model);
30 if (model != nullptr)
31 sensor_size = model->sensor_width_mm;
32 }
33 if (focal_length > 0.0f && sensor_size > 0.0f)
34 {
35 float flen = focal_length / sensor_size;
36 return std::make_pair(flen, FOCAL_LENGTH_AND_DATABASE);
37 }
38
39 /* Step 2: Check for 35mm equivalent focal length. */
40 float focal_length_35mm = exif.focal_length_35mm;
41 if (focal_length_35mm > 0.0f)
42 {
43 float flen = focal_length_35mm / 35.0f;
44 return std::make_pair(flen, FOCAL_LENGTH_35MM_EQUIV);
45 }
46
47 /* Step 3: Fall back to default value. */
48 return std::make_pair(1.0f, FOCAL_LENGTH_FALLBACK_VALUE);
49}
50
Camera database which, given a maker and model string, will look for a camera model in the database a...
CameraModel const * lookup(std::string const &maker, std::string const &model) const
Lookup of a camera model.
@ FOCAL_LENGTH_AND_DATABASE
@ FOCAL_LENGTH_35MM_EQUIV
@ FOCAL_LENGTH_FALLBACK_VALUE
std::pair< float, FocalLengthMethod > extract_focal_length(mve::image::ExifInfo const &exif)
Extracts the focal length from the EXIF tags of an image.
#define SFM_NAMESPACE_END
Definition defines.h:14
#define SFM_NAMESPACE_BEGIN
Definition defines.h:13
EXIF information.
Definition image_exif.h:32
std::string camera_maker
Camera manufacturer.
Definition image_exif.h:36
float focal_length_35mm
Focal length equivalent for 35mm film.
Definition image_exif.h:73
std::string camera_model
Camera model.
Definition image_exif.h:38
float focal_length
Focal length of the image in mm, relative to sensor size.
Definition image_exif.h:71
Representation of a digital camera.
float sensor_width_mm
The width of the sensor in milli meters.