-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor geotagging * move camera specific code to GeotagFromBlackVue * Move camera model/make extration to GeotagFromExif * Improve GPX interpolation error message * Add tests for offset_time and offset_angle * Parsing GoPro GPMF in tempdir
- Loading branch information
Showing
29 changed files
with
1,148 additions
and
1,209 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import os | ||
import typing as T | ||
|
||
from .geotag_from_generic import GeotagFromGeneric | ||
from .. import types | ||
from ..exif_read import ExifRead | ||
from ..error import MapillaryGeoTaggingError | ||
|
||
|
||
class GeotagFromEXIF(GeotagFromGeneric): | ||
def __init__(self, image_dir: str, images: T.List[str]): | ||
self.image_dir = image_dir | ||
self.images = images | ||
super().__init__() | ||
|
||
def to_description(self) -> T.List[types.FinalImageDescriptionOrError]: | ||
descs: T.List[types.FinalImageDescriptionOrError] = [] | ||
|
||
for image in self.images: | ||
image_path = os.path.join(self.image_dir, image) | ||
|
||
exif = ExifRead(image_path) | ||
|
||
lon, lat = exif.extract_lon_lat() | ||
if lat is None or lon is None: | ||
exc = MapillaryGeoTaggingError( | ||
"Unable to extract GPS Longitude or GPS Latitude from the image" | ||
) | ||
descs.append({"error": types.describe_error(exc), "filename": image}) | ||
continue | ||
|
||
timestamp = exif.extract_capture_time() | ||
if timestamp is None: | ||
exc = MapillaryGeoTaggingError( | ||
"Unable to extract timestamp from the image" | ||
) | ||
descs.append({"error": types.describe_error(exc), "filename": image}) | ||
continue | ||
|
||
angle = exif.extract_direction() | ||
|
||
desc: types.ImageDescriptionJSON = { | ||
"MAPLatitude": lat, | ||
"MAPLongitude": lon, | ||
"MAPCaptureTime": types.datetime_to_map_capture_time(timestamp), | ||
"filename": image, | ||
} | ||
if angle is not None: | ||
desc["MAPCompassHeading"] = { | ||
"TrueHeading": angle, | ||
"MagneticHeading": angle, | ||
} | ||
|
||
desc["MAPOrientation"] = exif.extract_orientation() | ||
|
||
make = exif.extract_make() | ||
if make is not None: | ||
desc["MAPDeviceMake"] = make | ||
|
||
model = exif.extract_model() | ||
if model is not None: | ||
desc["MAPDeviceModel"] = model | ||
|
||
descs.append(desc) | ||
|
||
return descs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import typing as T | ||
|
||
from .. import types | ||
|
||
|
||
class GeotagFromGeneric: | ||
def __init__(self): | ||
pass | ||
|
||
def to_description(self) -> T.List[types.FinalImageDescriptionOrError]: | ||
return [] |
Oops, something went wrong.