1#------------------------------------------------------------------------------
2# File:         DJI.pm
3#
4# Description:  DJI Phantom maker notes tags
5#
6# Revisions:    2016-07-25 - P. Harvey Created
7#               2017-06-23 - PH Added XMP tags
8#------------------------------------------------------------------------------
9
10package Image::ExifTool::DJI;
11
12use strict;
13use vars qw($VERSION);
14use Image::ExifTool::Exif;
15use Image::ExifTool::XMP;
16use Image::ExifTool::GPS;
17
18$VERSION = '1.02';
19
20my %convFloat2 = (
21    PrintConv => 'sprintf("%+.2f", $val)',
22    PrintConvInv => '$val',
23);
24
25# DJI maker notes (ref PH, mostly educated guesses based on DJI QuickTime::UserData tags)
26%Image::ExifTool::DJI::Main = (
27    WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
28    CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
29    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
30    NOTES => q{
31        This table lists tags found in the maker notes of images from some DJI
32        Phantom drones.
33    },
34    0x01 => { Name => 'Make',       Writable => 'string' },
35  # 0x02 - int8u[4]: "1 0 0 0", "1 1 0 0"
36    0x03 => { Name => 'SpeedX',     Writable => 'float', %convFloat2 }, # (guess)
37    0x04 => { Name => 'SpeedY',     Writable => 'float', %convFloat2 }, # (guess)
38    0x05 => { Name => 'SpeedZ',     Writable => 'float', %convFloat2 }, # (guess)
39    0x06 => { Name => 'Pitch',      Writable => 'float', %convFloat2 },
40    0x07 => { Name => 'Yaw',        Writable => 'float', %convFloat2 },
41    0x08 => { Name => 'Roll',       Writable => 'float', %convFloat2 },
42    0x09 => { Name => 'CameraPitch',Writable => 'float', %convFloat2 },
43    0x0a => { Name => 'CameraYaw',  Writable => 'float', %convFloat2 },
44    0x0b => { Name => 'CameraRoll', Writable => 'float', %convFloat2 },
45);
46
47%Image::ExifTool::DJI::XMP = (
48    %Image::ExifTool::XMP::xmpTableDefaults,
49    GROUPS => { 0 => 'XMP', 1 => 'XMP-drone-dji', 2 => 'Location' },
50    NAMESPACE => 'drone-dji',
51    TABLE_DESC => 'XMP DJI',
52    VARS => { NO_ID => 1 },
53    NOTES => 'XMP tags used by DJI for images from drones.',
54    AbsoluteAltitude  => { Writable => 'real' },
55    RelativeAltitude  => { Writable => 'real' },
56    GimbalRollDegree  => { Writable => 'real' },
57    GimbalYawDegree   => { Writable => 'real' },
58    GimbalPitchDegree => { Writable => 'real' },
59    FlightRollDegree  => { Writable => 'real' },
60    FlightYawDegree   => { Writable => 'real' },
61    FlightPitchDegree => { Writable => 'real' },
62    GpsLatitude => {
63        Name => 'GPSLatitude',
64        Writable => 'real',
65        Avoid => 1,
66        PrintConv    => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
67        PrintConvInv => 'Image::ExifTool::GPS::ToDegrees($val, 1)',
68    },
69    GpsLongtitude => { # (sic)
70        Name => 'GPSLongtitude',
71        Writable => 'real',
72        PrintConv    => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
73        PrintConvInv => 'Image::ExifTool::GPS::ToDegrees($val, 1)',
74    },
75    GpsLongitude => { #PH (NC)
76        Name => 'GPSLongitude',
77        Writable => 'real',
78        Avoid => 1,
79        PrintConv    => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
80        PrintConvInv => 'Image::ExifTool::GPS::ToDegrees($val, 1)',
81    },
82    FlightXSpeed  => { Writable => 'real' },
83    FlightYSpeed  => { Writable => 'real' },
84    FlightZSpeed  => { Writable => 'real' },
85    CamReverse    => { }, # integer?
86    GimbalReverse => { }, # integer?
87    SelfData      => { Groups => { 2 => 'Image' } },
88    CalibratedFocalLength    => { Writable => 'real', Groups => { 2 => 'Image' } },
89    CalibratedOpticalCenterX => { Writable => 'real', Groups => { 2 => 'Image' } },
90    CalibratedOpticalCenterY => { Writable => 'real', Groups => { 2 => 'Image' } },
91    RtkFlag       => { }, # integer?
92    RtkStdLon     => { Writable => 'real' },
93    RtkStdLat     => { Writable => 'real' },
94    RtkStdHgt     => { Writable => 'real' },
95    DewarpData    => { Groups => { 2 => 'Image' } },
96    DewarpFlag    => { Groups => { 2 => 'Image' } }, # integer?
97    Latitude => {
98        Name => 'Latitude',
99        Writable => 'real',
100        PrintConv    => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
101        PrintConvInv => 'Image::ExifTool::GPS::ToDegrees($val, 1)',
102    },
103    Longitude => {
104        Name => 'Longitude',
105        Writable => 'real',
106        PrintConv    => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
107        PrintConvInv => 'Image::ExifTool::GPS::ToDegrees($val, 1)',
108    },
109);
110
111__END__
112
113=head1 NAME
114
115Image::ExifTool::DJI - DJI Phantom maker notes tags
116
117=head1 SYNOPSIS
118
119This module is loaded automatically by Image::ExifTool when required.
120
121=head1 DESCRIPTION
122
123This module contains definitions required by Image::ExifTool to interpret
124the maker notes in images from some DJI Phantom drones.
125
126=head1 AUTHOR
127
128Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
129
130This library is free software; you can redistribute it and/or modify it
131under the same terms as Perl itself.
132
133=head1 SEE ALSO
134
135L<Image::ExifTool::TagNames/DJI Tags>,
136L<Image::ExifTool(3pm)|Image::ExifTool>
137
138=cut
139