"""Utility functions.
"""
import numpy as np
import logging
logger = logging.getLogger('lavaflow')
# -----------------------------------------------------------------------------
# Helpers
[docs]def get_lens_profile(tags):
"""Function to extract lens profile from exif.
Args:
tags (dict): lens profile extracted using https://exiftool.org/
Returns:
maker (str): camera maker string
model (str): camera model string
lens (str): lens model string
focal_length (double): focal length (mm)
aperture (double): aperture
distance (double): approximate focal distance (m)
"""
focus_distance_lower = tags.get("MakerNotes:FocusDistanceLower", None)
focus_distance_upper = tags.get("MakerNotes:FocusDistanceLower", None)
if focus_distance_lower and focus_distance_upper:
distance = (focus_distance_lower + focus_distance_upper) / 2
else:
distance = "unspecified"
profile = {
"maker": tags.get('EXIF:Make', "unspecified"),
"model": tags.get('EXIF:Model', "unspecified"),
"lens": tags.get('EXIF:LensModel', "unspecified"),
"focal_length": tags.get("EXIF:FocalLength", "unspecified"),
"aperture": tags.get("EXIF:ApertureValue", "unspecified"),
"distance": distance,
}
return profile