Skip to content

Commit e78a2ce

Browse files
committed
add dji config file for accurate m3m tags
1 parent 9334169 commit e78a2ce

7 files changed

Lines changed: 184 additions & 10 deletions

File tree

.github/workflows/lint-test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616

1717
- name: Install Exiftool
1818
run: |
19-
wget https://exiftool.org/Image-ExifTool-13.56.tar.gz
20-
gzip -dc Image-ExifTool-13.56.tar.gz | tar -xf -
21-
cd Image-ExifTool-13.56
19+
wget https://exiftool.org/Image-ExifTool-13.58.tar.gz
20+
gzip -dc Image-ExifTool-13.58.tar.gz | tar -xf -
21+
cd Image-ExifTool-13.58
2222
perl Makefile.PL
2323
sudo make install
2424
cd ..

cfg/dji.cfg

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#------------------------------------------------------------------------------
2+
# File: exiftool.cfg
3+
#
4+
# Description: This config file contains tag definitions needed to be able
5+
# to write Pix4D and Sentera XMP-Camera tags
6+
#
7+
# Usage: exiftool -config exiftool.cfg -XMP-camera:TAG=VAL ...
8+
#
9+
# Requires: ExifTool version 7.00 or later
10+
#
11+
# References: 1) https://support.pix4d.com/hc/en-us/articles/360016450032-Specifications-of-xmpcamera-tags
12+
#------------------------------------------------------------------------------
13+
14+
%Image::ExifTool::UserDefined = (
15+
'Image::ExifTool::XMP::Main' => {
16+
Camera => {
17+
SubDirectory => {
18+
TagTable => 'Image::ExifTool::UserDefined::Camera',
19+
},
20+
},
21+
'drone-dji' => {
22+
SubDirectory => {
23+
TagTable => 'Image::ExifTool::UserDefined::DJI',
24+
},
25+
},
26+
},
27+
);
28+
29+
%Image::ExifTool::UserDefined::Camera = (
30+
GROUPS => { 0 => 'XMP', 1 => 'XMP-Camera', 2 => 'Camera' },
31+
NAMESPACE => { 'Camera' => 'http://pix4d.com/camera/1.0/' },
32+
WRITABLE => 'string',
33+
Yaw => { Writable => 'real' },
34+
Pitch => { Writable => 'real' },
35+
Roll => { Writable => 'real' },
36+
IMUSampleSize => { Writable => 'integer' },
37+
IMUTimeOffset => { Writable => 'integer' },
38+
LineReadoutTime => { Writable => 'integer' },
39+
IMUFrequency => { Writable => 'real' },
40+
PrincipalPoint => { },
41+
ModelType => { },
42+
PerspectiveFocalLength => { Writable => 'real' },
43+
PerspectiveDistortion => { },
44+
IMULinearVelocity => { },
45+
GPSXYAccuracy => { Writable => 'real' },
46+
GPSZAccuracy => { Writable => 'real' },
47+
RigName => { },
48+
RigCameraIndex => { Writable => 'integer' },
49+
IMUAngularVelocity => {
50+
Binary => 1,
51+
ValueConv => 'Image::ExifTool::XMP::DecodeBase64($val)',
52+
ValueConvInv => 'Image::ExifTool::XMP::EncodeBase64($val)',
53+
},
54+
# added 2020/04/02 (ref 1)
55+
FisheyeAffineMatrix => { },
56+
FisheyeAffineSymmetric => { },
57+
FisheyePolynomial => { },
58+
RigRelatives => { },
59+
PerspectiveFocalLengthUnits => { },
60+
CentralWavelength => { List => 'Seq' },
61+
WavelengthFWHM => { List => 'Seq' },
62+
BlackCurrent => { List => 'Seq' },
63+
BandSensitivity => { List => 'Seq' },
64+
SunSensor => { List => 'Seq' },
65+
SunSensorExposureTime => { Writable => 'real' },
66+
SunSensorSensitivity => { List => 'Seq' },
67+
InvalidPixel => { List => 'Seq' },
68+
VignettingPolynomial => { List => 'Seq' },
69+
VignettingCenter => { List => 'Seq' },
70+
VignettingPolynomial2DName => { List => 'Seq' },
71+
VignettingPolynomial2D => { List => 'Seq' },
72+
ColorTransform => { List => 'Seq' },
73+
IsNormalized => { Writable => 'real' },
74+
Albedo => { List => 'Seq' },
75+
ReflectArea => { List => 'Seq' },
76+
CalibrationPicture => { Writable => 'integer' },
77+
GyroRate => { Writable => 'real' },
78+
IMUPitchAccuracy => { Writable => 'real' },
79+
IMURollAccuracy => { Writable => 'real' },
80+
IMUYawAccuracy => { Writable => 'real' },
81+
NominalCameraDistance => { Writable => 'real' },
82+
SunSensorYaw => { Writable => 'real' },
83+
SunSensorPitch => { Writable => 'real' },
84+
SunSensorRoll => { Writable => 'real' },
85+
SunSensorRelativeRotation => { Writable => 'real', List => 'Seq' },
86+
TransformAlpha => { List => 'Seq' },
87+
TransformBeta => { List => 'Seq' },
88+
TransformGamma => { List => 'Seq' },
89+
SensorBitDepth => { Writable => 'integer' },
90+
SensorTemperature => { Writable => 'real' },
91+
# (ref https://community.pix4d.com/t/camera-sun-irradiance-and-sun-angle-in-red-text/3290)
92+
IrradianceRelativeRotation => { },
93+
Irradiance => { List => 'Seq' },
94+
IrradianceExposureTime => { Writable => 'real' },
95+
IrradianceGain => { Writable => 'real' },
96+
BandName => { List => 'Seq' },
97+
# Not official pix4d fields
98+
);
99+
100+
%Image::ExifTool::UserDefined::DJI = (
101+
GROUPS => { 0 => 'XMP', 1 => 'XMP-drone-dji', 2 => 'drone-dji' },
102+
NAMESPACE => { 'drone-dji' => 'http://www.dji.com/drone-dji/1.0/' },
103+
WRITABLE => 'string',
104+
# Original GPS/flight tags from built-in DJI::XMP
105+
AbsoluteAltitude => { Writable => 'real' },
106+
RelativeAltitude => { Writable => 'real' },
107+
GimbalRollDegree => { Writable => 'real' },
108+
GimbalYawDegree => { Writable => 'real' },
109+
GimbalPitchDegree => { Writable => 'real' },
110+
FlightRollDegree => { Writable => 'real' },
111+
FlightYawDegree => { Writable => 'real' },
112+
FlightPitchDegree => { Writable => 'real' },
113+
GpsLatitude => { Writable => 'real' },
114+
GpsLongtitude => { Writable => 'real' },
115+
GpsLongitude => { Writable => 'real' },
116+
FlightXSpeed => { Writable => 'real' },
117+
FlightYSpeed => { Writable => 'real' },
118+
FlightZSpeed => { Writable => 'real' },
119+
CamReverse => { },
120+
GimbalReverse => { },
121+
SelfData => { },
122+
CalibratedFocalLength => { Writable => 'real' },
123+
CalibratedOpticalCenterX => { Writable => 'real' },
124+
CalibratedOpticalCenterY => { Writable => 'real' },
125+
RtkFlag => { },
126+
RtkStdLon => { Writable => 'real' },
127+
RtkStdLat => { Writable => 'real' },
128+
RtkStdHgt => { Writable => 'real' },
129+
DewarpData => { },
130+
DewarpFlag => { },
131+
Latitude => { Writable => 'real' },
132+
Longitude => { Writable => 'real' },
133+
# Multispectral / M3M tags
134+
ImageSource => { },
135+
GpsStatus => { },
136+
AltitudeType => { },
137+
RtkDiffAge => { Writable => 'real' },
138+
NTRIPMountPoint => { },
139+
NTRIPPort => { Writable => 'integer' },
140+
NTRIPHost => { },
141+
SurveryingMode => { Writable => 'integer' },
142+
UTCAtExposure => { },
143+
ShutterType => { },
144+
CameraSerialNumber => { },
145+
DroneModel => { },
146+
DroneSerialNumber => { },
147+
CaptureUUID => { },
148+
RelativeOpticalCenterX => { Writable => 'real' },
149+
RelativeOpticalCenterY => { Writable => 'real' },
150+
DewarpHMatrix => { List => 'Seq' },
151+
CalibratedHMatrix => { List => 'Seq' },
152+
VignettingFlag => { },
153+
VignettingData => { List => 'Seq' },
154+
LSType => { },
155+
LSstatus => { },
156+
Packageidx => { },
157+
Cfgcnt => { },
158+
RawData => { },
159+
BandFreq => { List => 'Seq' },
160+
Irradiance => { List => 'Seq' },
161+
SensorGain => { },
162+
SensorGainAdjustment => { },
163+
SensorIndex => { },
164+
BlackLevel => { },
165+
DroneID => { },
166+
);
167+
168+
1; #end

correct_images_dir.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata_datas = copy_metadata('imageio') + copy_metadata('imgcorrect')
1010
a = Analysis(['scripts\\correct_images.py'],
1111
pathex=['.'],
1212
binaries=[],
13-
datas=[('exiftool/exiftool.exe', '.'), ('cfg/exiftool.cfg', 'cfg'), ('cfg/reg_config.ini', 'cfg')] + metadata_datas,
13+
datas=[('exiftool/exiftool.exe', '.'), ('cfg/exiftool.cfg', 'cfg'), ('cfg/dji.cfg', 'cfg'), ('cfg/reg_config.ini', 'cfg')] + metadata_datas,
1414
hiddenimports=['pkg_resources.py2_warn'],
1515
hookspath=[],
1616
runtime_hooks=[],

correct_images_gui_onefile.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata_datas = copy_metadata('imageio') + copy_metadata('imgcorrect')
1010
a = Analysis(['scripts\\correct_images_gui.py'],
1111
pathex=['.'],
1212
binaries=[],
13-
datas=[('exiftool/exiftool.exe', '.'), ('cfg/exiftool.cfg', 'cfg'), ('cfg/reg_config.ini', 'cfg'), ('sentera_radiometric_corrections_icon.ico', '.')] + metadata_datas,
13+
datas=[('exiftool/exiftool.exe', '.'), ('cfg/exiftool.cfg', 'cfg'), ('cfg/dji.cfg', 'cfg'), ('cfg/reg_config.ini', 'cfg'), ('sentera_radiometric_corrections_icon.ico', '.')] + metadata_datas,
1414
hiddenimports=['pkg_resources.py2_warn'],
1515
hookspath=[],
1616
runtime_hooks=[],

correct_images_onefile.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata_datas = copy_metadata('imageio') + copy_metadata('imgcorrect')
1010
a = Analysis(['scripts\\correct_images.py'],
1111
pathex=['.'],
1212
binaries=[],
13-
datas=[('exiftool/exiftool.exe', '.'), ('cfg/exiftool.cfg', 'cfg'), ('cfg/reg_config.ini', 'cfg')] + metadata_datas,
13+
datas=[('exiftool/exiftool.exe', '.'), ('cfg/exiftool.cfg', 'cfg'), ('cfg/dji.cfg', 'cfg'), ('cfg/reg_config.ini', 'cfg')] + metadata_datas,
1414
hiddenimports=['pkg_resources.py2_warn'],
1515
hookspath=[],
1616
runtime_hooks=[],

imgcorrect/metadata.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010

1111
def copy_exif(image_df_row, exiftool_path):
1212
"""Copy image metadata with necessary changes from original image to corrected image."""
13+
parser = MetadataParser(image_df_row.image_path)
14+
1315
command = [
1416
exiftool_path,
15-
"-config",
16-
"cfg/exiftool.cfg",
17+
]
18+
make = parser.make()
19+
if make == "DJI":
20+
command += ["-config", "cfg/dji.cfg"]
21+
elif make == "Sentera":
22+
command += ["-config", "cfg/exiftool.cfg"]
23+
command += [
1724
"-overwrite_original",
1825
"-TagsFromFile",
1926
image_df_row.image_path,
@@ -25,7 +32,6 @@ def copy_exif(image_df_row, exiftool_path):
2532
"-xmp-Camera:BlackCurrent=0",
2633
]
2734
if image_df_row.reduce_xmp:
28-
parser = MetadataParser(image_df_row.image_path)
2935
cent_arr, fwhm_arr = parser.wavelength_data()
3036
band_arr = parser.bandnames()
3137
i = int(image_df_row.XMP_index)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "imgcorrect"
3-
version = "2.1.2"
3+
version = "2.1.3"
44
description = "Library to perform various corrections on imagery from supported sensors"
55
authors = ["Samuel Williams <sam.williams@sentera.com>", "Joseph Franck <joseph.franck@sentera.com>"]
66

0 commit comments

Comments
 (0)