-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_python.py
More file actions
96 lines (84 loc) · 2.76 KB
/
example_python.py
File metadata and controls
96 lines (84 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import os
from camera2geo import *
working_directory = os.getcwd()
# %% Search for cameras
# cameras = search_cameras(
# cam_maker = "DJI",
# cam_model = "Mavic Pro"
# )
# %% Search lenses
# search_lenses(
# cameras[0],
# lens_maker = "DJI",
# lens_model = "Mavic Pro"
# )
# %% Prop data
# add_relative_altitude_to_csv(
# csv_path = "/path/to/metadata/csv/file.csv",
# lat_field="lat",
# lon_field="lon",
# absolute_field="abs_alt",
# output_field="rel_alt",
# elevation_raster_path="/elevation/raster/image.tif",
# )
# %% Add image metadata or remove it by setting to None
# Remove metadata fields from DJI_0812.JPG for test
apply_metadata(
input_images=f"{working_directory}/data_mavic2pro/input/DJI_0812.JPG",
metadata={
"EXIF:FocalLength":None,
"EXIF:GPSLatitude":None,
"EXIF:GPSLongitude":None,
},
)
# Add fields back
apply_metadata(
input_images=f"{working_directory}/data_mavic2pro/input/DJI_0812.JPG",
metadata={
# "EXIF:GPSLatitude":None,
# "EXIF:GPSLongitude":None,
"EXIF:FocalLength":10.26, # Correct value: 10.26
# "EXIF:FocalLengthIn35mmFormat":None,
# "XMP:RelativeAltitude":None,
# "XMP:AbsoluteAltitude":None,
# "XMP:GimbalRollDegree":None,
# "XMP:GimbalPitchDegree":None,
# "XMP:GimbalYawDegree":None,
# "XMP:FlightPitchDegree":None,
# "XMP:FlightRollDegree":None,
# "XMP:FlightYawDegree":None,
# "EXIF:ImageWidth":None,
# "EXIF:ImageHeight":None,
# "EXIF:MaxApertureValue":None,
# "EXIF:DateTimeOriginal":None,
# "EXIF:Model":"Nikon D850",
# "XMP:RigCameraIndex":3,
# "sensor_make":"Nikon",
},
csv_metadata_path=f"{working_directory}/data_mavic2pro/input/metadata.csv",
csv_field_to_header={
"name":"name",
"EXIF:GPSLatitude":"lat", # Correct value: 19.5133791944444,
"EXIF:GPSLongitude":"lon",# Correct value: -154.857850888889
# "XMP:AbsoluteAltitude":"abs_alt",
# "XMP:RelativeAltitude":"rel_alt",
# "XMP:GimbalRollDegree":"omega",
# "XMP:GimbalPitchDegree":"phi",
# "XMP:GimbalYawDegree":"kappa",
},
)
# %% Read current metadata used in main function, first value in list takes president over subsequent ones
read_metadata(
input_images=f"{working_directory}/data_mavic2pro/input/*.JPG"
)
# %% Camera space to geographic space for mavic 2 pro test images
camera2geo(
input_images=f"{working_directory}/data_mavic2pro/input/*.JPG",
output_images= f"{working_directory}/data_mavic2pro/output/$.tif",
epsg = 4326,
correct_magnetic_declination = False,
cog = True,
image_equalize = False,
lens_correction = True,
elevation_data = True,
)