Image/ExifTool/Parrot.pm untested

filter: Statementstmt 0.0% 0 / 118 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 152 CC 9 SCAR 42.2
CC
9
Cov
0%
Process_mett
90.0
BEGIN
2.0
BEGIN
2.0
CRAP 68.0
1 #------------------------------------------------------------------------------
2 # File: Parrot.pm
3 #
4 # Description: Read timed metadata from Parrot drone videos
5 #
6 # Revisions: 2019-10-23 - P. Harvey Created
7 #
8 # References: 1) https://developer.parrot.com/docs/pdraw/metadata.html
9 # --> changed to https://developer.parrot.com/docs/pdraw/video-metadata.html
10 #------------------------------------------------------------------------------
11  
12 package Image::ExifTool::Parrot;
13  
14 use strict;
15 use vars qw($VERSION);
16 use Image::ExifTool qw(:DataAccess :Utils);
17  
18 $VERSION = '1.03';
19  
20 sub Process_mett($$$);
21  
22 # tags found in Parrot 'mett' timed metadata (ref 1)
23 %Image::ExifTool::Parrot::mett = (
24 PROCESS_PROC => \&Process_mett,
25 # put the 'P' records first in the documentation
26 VARS => {
27 SORT_PROC => sub { my ($a,$b)=@_; $a=~s/P/A/; $b=~s/P/A/; $a cmp $b },
28 LONG_TAGS => 1
29 },
30 NOTES => q{
31 Streaming metadata found in Parrot drone videos. See
32 L<https://developer.parrot.com/docs/pdraw/metadata.html> for the
33 specification.
34 },
35 P1 => {
36 Name => 'ParrotV1',
37 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::V1' },
38 },
39 P2 => {
40 Name => 'ParrotV2',
41 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::V2' },
42 },
43 P3 => {
44 Name => 'ParrotV3',
45 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::V3' },
46 },
47 E1 => {
48 Name => 'ParrotTimeStamp',
49 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::TimeStamp' },
50 },
51 E2 => {
52 Name => 'ParrotFollowMe',
53 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::FollowMe' },
54 },
55 E3 => {
56 Name => 'ParrotAutomation',
57 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::Automation' },
58 },
59 # MetaType of timed metadata written by ARCore (see forum13653)
60 'application/arcore-accel' => {
61 Name => 'ARCoreAccel',
62 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::ARCoreAccel', ByteOrder => 'II' },
63 },
64 'application/arcore-accel-0' => {
65 Name => 'ARCoreAccel0',
66 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::ARCoreAccel0', ByteOrder => 'II' },
67 },
68 'application/arcore-gyro' => {
69 Name => 'ARCoreGyro',
70 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::ARCoreGyro', ByteOrder => 'II' },
71 },
72 'application/arcore-gyro-0' => {
73 Name => 'ARCoreGyro0',
74 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::ARCoreGyro0', ByteOrder => 'II' },
75 },
76 'application/arcore-video-0' => {
77 Name => 'ARCoreVideo',
78 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::ARCoreVideo', ByteOrder => 'II' },
79 },
80 'application/arcore-custom-event' => {
81 Name => 'ARCoreCustom',
82 SubDirectory => { TagTable => 'Image::ExifTool::Parrot::ARCoreCustom', ByteOrder => 'II' },
83 },
84 );
85  
86 # tags found in the Parrot 'mett' V1 timed metadata (ref 1) [untested]
87 %Image::ExifTool::Parrot::V1 = (
88 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
89 NOTES => 'Parrot version 1 streaming metadata.',
90 GROUPS => { 2 => 'Location' },
91 4 => {
92 Name => 'DroneYaw',
93 Format => 'int16s',
94 ValueConv => '$val / 0x1000 * 180 / 3.14159', # convert from rad to deg
95 },
96 6 => {
97 Name => 'DronePitch',
98 Format => 'int16s',
99 ValueConv => '$val / 0x1000 * 180 / 3.14159',
100 },
101 8 => {
102 Name => 'DroneRoll',
103 Format => 'int16s',
104 ValueConv => '$val / 0x1000 * 180 / 3.14159',
105 },
106 10 => {
107 Name => 'CameraPan',
108 Format => 'int16s',
109 ValueConv => '$val / 0x1000 * 180 / 3.14159',
110 },
111 12 => {
112 Name => 'CameraTilt',
113 Format => 'int16s',
114 ValueConv => '$val / 0x1000 * 180 / 3.14159',
115 },
116 14 => {
117 Name => 'FrameView', # (W,X,Y,Z)
118 Format => 'int16s[4]',
119 ValueConv => 'my @a = split " ",$val; $_ /= 0x1000 foreach @a; "@a"',
120 },
121 22 => {
122 Name => 'ExposureTime',
123 Groups => { 2 => 'Camera' },
124 Format => 'int16s',
125 ValueConv => '$val / 0x100 / 1000',
126 PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
127 },
128 24 => {
129 Name => 'ISO',
130 Groups => { 2 => 'Camera' },
131 Format => 'int16s',
132 },
133 26 => {
134 Name => 'WifiRSSI',
135 Groups => { 2 => 'Device' },
136 Format => 'int8s',
137 PrintConv => '"$val dBm"',
138 },
139 27 => {
140 Name => 'Battery',
141 Groups => { 2 => 'Device' },
142 PrintConv => '"$val %"',
143 },
144 28 => {
145 Name => 'GPSLatitude',
146 Format => 'int32s',
147 ValueConv => '$val / 0x100000',
148 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
149 },
150 32 => {
151 Name => 'GPSLongitude',
152 Format => 'int32s',
153 ValueConv => '$val / 0x100000',
154 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
155 },
156 36 => {
157 Name => 'GPSAltitude',
158 Format => 'int32s',
159 Mask => 0xffffff00,
160 ValueConv => '$val / 0x100',
161 PrintConv => 'sprintf("%.3f m", $val)',
162 },
163 36.1 => {
164 Name => 'GPSSatellites', # (SV count)
165 Format => 'int32s',
166 Mask => 0xff,
167 },
168 40 => {
169 Name => 'AltitudeFromTakeOff',
170 Format => 'int32s',
171 ValueConv => '$val / 0x10000',
172 PrintConv => 'sprintf("%.3f m", $val)',
173 },
174 44 => {
175 Name => 'DistanceFromHome',
176 Format => 'int32u',
177 ValueConv => '$val / 0x10000',
178 },
179 48 => {
180 Name => 'SpeedX',
181 Format => 'int16s',
182 ValueConv => '$val / 0x100',
183 },
184 50 => {
185 Name => 'SpeedY',
186 Format => 'int16s',
187 ValueConv => '$val / 0x100',
188 },
189 52 => {
190 Name => 'SpeedZ',
191 Format => 'int16s',
192 ValueConv => '$val / 0x100',
193 },
194 54 => {
195 Name => 'Binning',
196 Groups => { 2 => 'Device' },
197 Mask => 0x80,
198 },
199 54.1 => {
200 Name => 'FlyingState',
201 Groups => { 2 => 'Device' },
202 Mask => 0x7f,
203 PrintConv => {
204 0 => 'Landed',
205 1 => 'Taking Off',
206 2 => 'Hovering',
207 3 => 'Flying',
208 4 => 'Landing',
209 5 => 'Emergency',
210 },
211 },
212 55 => {
213 Name => 'Animation',
214 Groups => { 2 => 'Device' },
215 Mask => 0x80,
216 },
217 55.1 => {
218 Name => 'PilotingMode',
219 Groups => { 2 => 'Device' },
220 Mask => 0x7f,
221 PrintConv => {
222 0 => 'Manual',
223 1 => 'Return Home',
224 2 => 'Flight Plan',
225 3 => 'Follow Me',
226 },
227 },
228 );
229  
230 # tags found in the Parrot 'mett' V2 timed metadata (ref 1) [untested]
231 %Image::ExifTool::Parrot::V2 = (
232 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
233 Groups => { 2 => 'Location' },
234 NOTES => 'Parrot version 2 basic streaming metadata.',
235 4 => {
236 Name => 'Elevation',
237 Notes => 'estimated distance from ground',
238 Format => 'int32s',
239 ValueConv => '$val / 0x10000',
240 PrintConv => 'sprintf("%.3f m", $val)',
241 },
242 8 => {
243 Name => 'GPSLatitude',
244 Format => 'int32s',
245 ValueConv => '$val / 0x400000',
246 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
247 },
248 12 => {
249 Name => 'GPSLongitude',
250 Format => 'int32s',
251 ValueConv => '$val / 0x400000',
252 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
253 },
254 16 => {
255 Name => 'GPSAltitude',
256 Format => 'int32s',
257 Mask => 0xffffff00,
258 ValueConv => '$val / 0x100',
259 PrintConv => 'sprintf("%.3f m", $val)',
260 },
261 16.1 => {
262 Name => 'GPSSatellites', # (SV count)
263 Format => 'int32s',
264 Mask => 0xff,
265 },
266 20 => {
267 Name => 'GPSVelocityNorth', # (m/s)
268 Format => 'int16s',
269 ValueConv => '$val / 0x100',
270 },
271 22 => {
272 Name => 'GPSVelocityEast', # (m/s)
273 Format => 'int16s',
274 ValueConv => '$val / 0x100',
275 },
276 24 => {
277 Name => 'GPSVelocityDown', # (m/s)
278 Format => 'int16s',
279 ValueConv => '$val / 0x100',
280 },
281 26 => {
282 Name => 'AirSpeed', # (m/s)
283 Format => 'int16s',
284 RawConv => '$val < 0 ? undef : $val',
285 ValueConv => '$val / 0x100',
286 },
287 28 => {
288 Name => 'DroneQuaternion', # (W,X,Y,Z)
289 Format => 'int16s[4]',
290 ValueConv => 'my @a = split " ",$val; $_ /= 0x4000 foreach @a; "@a"',
291 },
292 36 => {
293 Name => 'FrameView', # (W,X,Y,Z)
294 Format => 'int16s[4]',
295 ValueConv => 'my @a = split " ",$val; $_ /= 0x4000 foreach @a; "@a"',
296 },
297 44 => {
298 Name => 'CameraPan',
299 Format => 'int16s',
300 ValueConv => '$val / 0x1000 * 180 / 3.14159', # convert from rad to deg
301 },
302 46 => {
303 Name => 'CameraTilt',
304 Format => 'int16s',
305 ValueConv => '$val / 0x1000 * 180 / 3.14159',
306 },
307 48 => {
308 Name => 'ExposureTime',
309 Groups => { 2 => 'Camera' },
310 Format => 'int16u',
311 ValueConv => '$val / 0x100 / 1000',
312 PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
313 },
314 50 => {
315 Name => 'ISO',
316 Groups => { 2 => 'Camera' },
317 Format => 'int16u',
318 },
319 52 => {
320 Name => 'Binning',
321 Groups => { 2 => 'Device' },
322 Mask => 0x80,
323 },
324 52.1 => {
325 Name => 'FlyingState',
326 Groups => { 2 => 'Device' },
327 Mask => 0x7f,
328 PrintConv => {
329 0 => 'Landed',
330 1 => 'Taking Off',
331 2 => 'Hovering',
332 3 => 'Flying',
333 4 => 'Landing',
334 5 => 'Emergency',
335 6 => 'User Takeoff',
336 7 => 'Motor Ramping',
337 8 => 'Emergency Landing',
338 },
339 },
340 53 => {
341 Name => 'Animation',
342 Groups => { 2 => 'Device' },
343 Mask => 0x80,
344 },
345 53.1 => {
346 Name => 'PilotingMode',
347 Groups => { 2 => 'Device' },
348 Mask => 0x7f,
349 PrintConv => {
350 0 => 'Manual',
351 1 => 'Return Home',
352 2 => 'Flight Plan',
353 3 => 'Follow Me / Tracking', # (same as 'Tracking')
354 4 => 'Magic Carpet',
355 5 => 'Move To',
356 },
357 },
358 54 => {
359 Name => 'WifiRSSI',
360 Groups => { 2 => 'Device' },
361 Format => 'int8s',
362 PrintConv => '"$val dBm"',
363 },
364 55 => {
365 Name => 'Battery',
366 Groups => { 2 => 'Device' },
367 PrintConv => '"$val %"',
368 },
369 );
370  
371 # tags found in the Parrot 'mett' V3 timed metadata (ref 1)
372 %Image::ExifTool::Parrot::V3 = (
373 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
374 GROUPS => { 2 => 'Location' },
375 NOTES => 'Parrot version 3 basic streaming metadata.',
376 4 => {
377 Name => 'Elevation',
378 Notes => 'estimated distance from ground',
379 Format => 'int32s',
380 ValueConv => '$val / 0x10000',
381 PrintConv => 'sprintf("%.3f m", $val)',
382 },
383 8 => {
384 Name => 'GPSLatitude',
385 Format => 'int32s',
386 ValueConv => '$val / 0x400000',
387 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
388 },
389 12 => {
390 Name => 'GPSLongitude',
391 Format => 'int32s',
392 ValueConv => '$val / 0x400000',
393 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
394 },
395 16 => {
396 Name => 'GPSAltitude',
397 Format => 'int32s',
398 Mask => 0xffffff00,
399 ValueConv => '$val / 0x100',
400 PrintConv => 'sprintf("%.3f m", $val)',
401 },
402 16.1 => {
403 Name => 'GPSSatellites', # (SV count)
404 Format => 'int32s',
405 Mask => 0xff,
406 },
407 20 => {
408 Name => 'GPSVelocityNorth', # (m/s)
409 Format => 'int16s',
410 ValueConv => '$val / 0x100',
411 },
412 22 => {
413 Name => 'GPSVelocityEast', # (m/s)
414 Format => 'int16s',
415 ValueConv => '$val / 0x100',
416 },
417 24 => {
418 Name => 'GPSVelocityDown', # (m/s)
419 Format => 'int16s',
420 ValueConv => '$val / 0x100',
421 },
422 26 => {
423 Name => 'AirSpeed', # (m/s)
424 Format => 'int16s',
425 RawConv => '$val < 0 ? undef : $val',
426 ValueConv => '$val / 0x100',
427 },
428 28 => {
429 Name => 'DroneQuaternion', # (W,X,Y,Z)
430 Format => 'int16s[4]',
431 ValueConv => 'my @a = split " ",$val; $_ /= 0x4000 foreach @a; "@a"',
432 },
433 36 => {
434 Name => 'FrameBaseView', # (W,X,Y,Z without pan/tilt)
435 Format => 'int16s[4]',
436 ValueConv => 'my @a = split " ",$val; $_ /= 0x4000 foreach @a; "@a"',
437 },
438 44 => {
439 Name => 'FrameView', # (W,X,Y,Z)
440 Format => 'int16s[4]',
441 ValueConv => 'my @a = split " ",$val; $_ /= 0x4000 foreach @a; "@a"',
442 },
443 52 => {
444 Name => 'ExposureTime',
445 Groups => { 2 => 'Camera' },
446 Format => 'int16u',
447 ValueConv => '$val / 0x100 / 1000',
448 PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
449 },
450 54 => {
451 Name => 'ISO',
452 Groups => { 2 => 'Camera' },
453 Format => 'int16u',
454 },
455 56 => {
456 Name => 'RedBalance',
457 Groups => { 2 => 'Camera' },
458 Format => 'int16u',
459 ValueConv => '$val / 0x4000',
460 },
461 58 => {
462 Name => 'BlueBalance',
463 Groups => { 2 => 'Camera' },
464 Format => 'int16u',
465 ValueConv => '$val / 0x4000',
466 },
467 60 => {
468 Name => 'FOV', # (degrees)
469 Description => 'Field Of View',
470 Notes => 'horizontal and vertical field of view in degrees',
471 Groups => { 2 => 'Image' },
472 Format => 'int16u[2]',
473 ValueConv => 'my @a = split " ",$val; $_ /= 0x100 foreach @a; "@a"',
474 },
475 64 => {
476 Name => 'LinkGoodput',
477 Groups => { 2 => 'Device' },
478 Format => 'int32u',
479 Mask => 0xffffff00,
480 PrintConv => '"$val kbit/s"',
481 },
482 64.1 => {
483 Name => 'LinkQuality',
484 Groups => { 2 => 'Device' },
485 Format => 'int32u',
486 Notes => '0-5',
487 Mask => 0xff,
488 },
489 68 => {
490 Name => 'WifiRSSI',
491 Groups => { 2 => 'Device' },
492 Format => 'int8s',
493 PrintConv => '"$val dBm"',
494 },
495 69 => {
496 Name => 'Battery',
497 Groups => { 2 => 'Device' },
498 PrintConv => '"$val %"',
499 },
500 70 => {
501 Name => 'Binning',
502 Groups => { 2 => 'Device' },
503 Mask => 0x80,
504 },
505 70.1 => {
506 Name => 'FlyingState',
507 Groups => { 2 => 'Device' },
508 Mask => 0x7f,
509 PrintConv => {
510 0 => 'Landed',
511 1 => 'Taking Off',
512 2 => 'Hovering',
513 3 => 'Flying',
514 4 => 'Landing',
515 5 => 'Emergency',
516 6 => 'User Takeoff',
517 7 => 'Motor Ramping',
518 8 => 'Emergency Landing',
519 },
520 },
521 71 => {
522 Name => 'Animation',
523 Groups => { 2 => 'Device' },
524 Mask => 0x80,
525 },
526 71.1 => {
527 Name => 'PilotingMode',
528 Groups => { 2 => 'Device' },
529 Mask => 0x7f,
530 PrintConv => {
531 0 => 'Manual',
532 1 => 'Return Home',
533 2 => 'Flight Plan',
534 3 => 'Follow Me / Tracking', # (same as 'Tracking')
535 4 => 'Magic Carpet',
536 5 => 'Move To',
537 },
538 },
539 );
540  
541 # tags found in the Parrot 'mett' E1 timestamp timed metadata (ref 1)
542 %Image::ExifTool::Parrot::TimeStamp = (
543 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
544 NOTES => 'Parrot streaming metadata timestamp extension.',
545 GROUPS => { 2 => 'Time' },
546 4 => {
547 Name => 'TimeStamp',
548 Format => 'int64u',
549 ValueConv => '$val / 1e6',
550 },
551 );
552  
553 # tags found in the Parrot 'mett' E2 follow-me timed metadata (ref 1) [untested]
554 %Image::ExifTool::Parrot::FollowMe = (
555 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
556 GROUPS => { 2 => 'Location' },
557 NOTES => 'Parrot streaming metadata follow-me extension.',
558 4 => {
559 Name => 'GPSTargetLatitude',
560 Format => 'int32s',
561 ValueConv => '$val / 0x400000',
562 },
563 8 => {
564 Name => 'GPSTargetLongitude',
565 Format => 'int32s',
566 ValueConv => '$val / 0x400000',
567 },
568 12 => {
569 Name => 'GPSTargetAltitude',
570 Format => 'int32s',
571 ValueConv => '$val / 0x10000',
572 },
573 16 => {
574 Name => 'Follow-meMode',
575 Groups => { 2 => 'Device' },
576 PrintConv => { BITMASK => {
577 0 => 'Follow-me enabled',
578 1 => 'Follow-me', # (0=Look-at-me! auggh. see AutomationFlags below)
579 2 => 'Angle locked',
580 }},
581 },
582 17 => {
583 Name => 'Follow-meAnimation',
584 Groups => { 2 => 'Device' },
585 PrintConv => {
586 0 => 'None',
587 1 => 'Orbit',
588 2 => 'Boomerang',
589 3 => 'Parabola',
590 4 => 'Zenith',
591 },
592 },
593 );
594  
595 # tags found in the Parrot 'mett' E3 automation timed metadata (ref 1)
596 %Image::ExifTool::Parrot::Automation = (
597 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
598 GROUPS => { 2 => 'Location' },
599 NOTES => 'Parrot streaming metadata automation extension.',
600 4 => {
601 Name => 'GPSFramingLatitude',
602 Format => 'int32s',
603 ValueConv => '$val / 0x400000',
604 },
605 8 => {
606 Name => 'GPSFramingLongitude',
607 Format => 'int32s',
608 ValueConv => '$val / 0x400000',
609 },
610 12 => {
611 Name => 'GPSFramingAltitude',
612 Format => 'int32s',
613 ValueConv => '$val / 0x10000',
614 },
615 16 => {
616 Name => 'GPSDestLatitude',
617 Format => 'int32s',
618 ValueConv => '$val / 0x400000',
619 },
620 20 => {
621 Name => 'GPSDestLongitude',
622 Format => 'int32s',
623 ValueConv => '$val / 0x400000',
624 },
625 24 => {
626 Name => 'GPSDestAltitude',
627 Format => 'int32s',
628 ValueConv => '$val / 0x10000',
629 },
630 28 => {
631 Name => 'AutomationAnimation',
632 Groups => { 2 => 'Device' },
633 PrintConv => {
634 0 => 'None',
635 1 => 'Orbit',
636 2 => 'Boomerang',
637 3 => 'Parabola',
638 4 => 'Dolly Slide',
639 5 => 'Dolly Zoom',
640 6 => 'Reveal Vertical',
641 7 => 'Reveal Horizontal',
642 8 => 'Candle',
643 9 => 'Flip Front',
644 10 => 'Flip Back',
645 11 => 'Flip Left',
646 12 => 'Flip Right',
647 13 => 'Twist Up',
648 14 => 'Position Twist Up',
649 },
650 },
651 29 => {
652 Name => 'AutomationFlags',
653 Groups => { 2 => 'Device' },
654 PrintConv => { BITMASK => {
655 0 => 'Follow-me enabled',
656 1 => 'Look-at-me enabled', # (really? opposite sense to Follow-meMode above!)
657 2 => 'Angle locked',
658 }},
659 },
660 );
661  
662 # ARCore Accel data (ref PH)
663 %Image::ExifTool::Parrot::ARCoreAccel = (
664 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
665 GROUPS => { 2 => 'Location' },
666 NOTES => 'ARCore accelerometer data.',
667 FIRST_ENTRY => 0,
668 # 00-04: always 10 34 16 1 29
669 4 => {
670 Name => 'AccelerometerUnknown',
671 Format => 'undef[16]',
672 Unknown => 1,
673 ValueConv => 'join " ", unpack("Cx4Cx4Cx4C", $val)',
674 },
675 5 => { # (NC)
676 Name => 'Accelerometer',
677 Format => 'undef[14]',
678 RawConv => 'GetFloat(\$val,0) . " " . GetFloat(\$val,5) . " " . GetFloat(\$val,10)',
679 },
680 # 05-08: float Accelerometer X
681 # 09: 37
682 # 10-13: float Accelerometer Y
683 # 14: 45
684 # 15-18: float Accelerometer Z
685 # 19: 48
686 # 20-24: 128-255
687 # 25: 246 then 247
688 # 26: 188
689 # 27: 2
690 # 28: 56
691 # 29-32: 128-255
692 # 33: increments slowly (about once every 56 samples or so)
693 );
694  
695 # ARCore Accel data (ref PH)
696 %Image::ExifTool::Parrot::ARCoreAccel0 = (
697 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
698 GROUPS => { 2 => 'Location' },
699 NOTES => 'ARCore accelerometer data.',
700 FIRST_ENTRY => 0,
701 9 => { # (NC)
702 Name => 'Accelerometer',
703 Format => 'undef[14]',
704 RawConv => 'GetFloat(\$val,0) . " " . GetFloat(\$val,5) . " " . GetFloat(\$val,10)',
705 },
706 );
707  
708 # ARCore Gyro data (ref PH)
709 %Image::ExifTool::Parrot::ARCoreGyro = (
710 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
711 GROUPS => { 2 => 'Location' },
712 NOTES => 'ARCore gyro data.',
713 FIRST_ENTRY => 0,
714 # 00-04: always 10 34 16 3 29
715 4 => {
716 Name => 'GyroscopeUnknown',
717 Format => 'undef[16]',
718 Unknown => 1, # always "29 37 45 48" in my sample, just like AccelerometerUnknown
719 ValueConv => 'join " ", unpack("Cx4Cx4Cx4C", $val)',
720 },
721 5 => { # (NC)
722 Name => 'Gyroscope',
723 Format => 'undef[14]',
724 RawConv => 'GetFloat(\$val,0) . " " . GetFloat(\$val,5) . " " . GetFloat(\$val,10)',
725 },
726 );
727  
728 # ARCore Gyro data (ref PH)
729 %Image::ExifTool::Parrot::ARCoreGyro0 = (
730 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
731 GROUPS => { 2 => 'Location' },
732 NOTES => 'ARCore gyro data.',
733 FIRST_ENTRY => 0,
734 9 => { # (NC)
735 Name => 'Gyroscope',
736 Format => 'undef[14]',
737 RawConv => 'GetFloat(\$val,0) . " " . GetFloat(\$val,5) . " " . GetFloat(\$val,10)',
738 },
739 );
740  
741 %Image::ExifTool::Parrot::ARCoreVideo = (
742 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
743 FIRST_ENTRY => 0,
744 );
745  
746 %Image::ExifTool::Parrot::ARCoreCustom = (
747 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
748 FIRST_ENTRY => 0,
749 );
750  
751 %Image::ExifTool::Parrot::Composite = (
752 GPSDateTime => {
753 Description => 'GPS Date/Time',
754 Groups => { 2 => 'Time' },
755 SubDoc => 1,
756 Require => {
757 0 => 'Parrot:GPSLatitude', # (avoids creating this tag for other videos)
758 1 => 'Main:CreateDate',
759 2 => 'SampleTime',
760 },
761 ValueConv => q{
762 my $time = $val[1];
763 my $diff = $val[2];
764 # handle time zone and shift to UTC
765 if ($time =~ s/([-+])(\d{1,2}):?(\d{2})$//) {
766 my $secs = (($2 * 60) + $3) * 60;
767 $secs *= -1 if $1 eq '+';
768 $diff += $secs;
769 } elsif ($time !~ s/Z$//) {
770 # shift from local time
771 $diff += GetUnixTime($time, 1) - GetUnixTime($time);
772 }
773 my $sign = ($diff =~ s/^-// ? '-' : '');
774 $time .= '.000'; # add decimal seconds
775 ShiftTime($time, "${sign}0:0:$diff");
776 return $time . 'Z';
777 },
778 PrintConv => '$self->ConvertDateTime($val)',
779 },
780 );
781  
782 # add our composite tags
783 Image::ExifTool::AddCompositeTags('Image::ExifTool::Parrot');
784  
785  
786 #------------------------------------------------------------------------------
787 # Parse Parrot 'mett' timed metadata
788 # Inputs: 0) ExifTool ref, 1) dirInfo ref, 2) tag table ref
789 # Returns: 1 on success
790 # (this metadata design is really stupid -- you need to know the size of the base structures)
791 sub Process_mett($$$)
792 {
793 my ($et, $dirInfo, $tagTbl) = @_;
794 my $dataPt = $$dirInfo{DataPt};
795 my $dataPos = $$dirInfo{DataPos};
796 my $dirEnd = length $$dataPt;
797 my $pos = $$dirInfo{DirStart} || 0;
798 my $metaType = $$et{MetaType} || '';
799  
800 $et->VerboseDir('Parrot mett', undef, $dirEnd);
801  
802 if ($$tagTbl{$metaType}) {
803 # loop through ARCore records
804 while ($pos < $dirEnd - 2) {
805 last unless substr($$dataPt,$pos,1) eq "\x0a";
806 my $len = ord(substr($$dataPt, $pos+1, 1));
807 if ($pos + $len + 2 > $dirEnd) {
808 $et->Warn("Unexpected length for $metaType record", 1);
809 last;
810 }
811 $len or $len = $dirEnd - $pos - 2; # use entire record if length is 0
812 $et->HandleTag($tagTbl, $metaType, undef,
813 DataPt => $dataPt,
814 DataPos => $dataPos,
815 DirStart => $pos,
816 DirLen => $len,
817 Base => $$dirInfo{Base},
818 );
819 $pos += $len + 2;
820 }
821 return 1;
822 }
823 while ($pos + 4 < $dirEnd) {
824 my ($id, $nwords) = unpack("x${pos}a2n", $$dataPt);
825 my $size;
826 if ($id !~ /^[EP]\d/) {
827 # no ID so this should be a 60-byte V1 recording record, otherwise give up
828 last unless $dirEnd == 60;
829 $id = 'P1'; # generate a fake ID
830 # ignore the first 4 of the record so the fields will align with
831 # the other V1 records (unfortunately, this means that we won't
832 # decode the V1 recording frame timestamp, but oh well)
833 $pos += 4;
834 $size = $dirEnd - $pos;
835 # must override size for P3 and P3 records since it includes the extensions (augh!)
836 } elsif ($id eq 'P2') {
837 $size = 56;
838 } elsif ($id eq 'P3') {
839 $size = 72;
840 } else {
841 $size = $nwords * 4 + 4;
842 }
843 last if $pos + $size > $dirEnd;
844 $et->HandleTag($tagTbl, $id, undef,
845 DataPt => $dataPt,
846 DataPos => $dataPos,
847 Base => $$dirInfo{Base},
848 Start => $pos,
849 Size => $size,
850 );
851 $pos += $size;
852 }
853 return 1;
854 }
855  
856 1; # end
857  
858 __END__