Forum

Author Topic: Using Yaw Pitch Roll from DJI Drones  (Read 20534 times)

doctorben

  • Newbie
  • *
  • Posts: 9
    • View Profile
Using Yaw Pitch Roll from DJI Drones
« on: February 24, 2016, 04:35:58 PM »
I want to ask if it is possible or perhabs make any sense to use the yaw-/ -pitch- and roll-data from DJI-drones >> image xmp-metadata like follows:

<drone-dji:AbsoluteAltitude>+0.00</drone-dji:AbsoluteAltitude>
<drone-dji:RelativeAltitude>+0.00</drone-dji:RelativeAltitude>
<drone-dji:GimbalRollDegree>+0.00</drone-dji:GimbalRollDegree>
<drone-dji:GimbalYawDegree>-129.90</drone-dji:GimbalYawDegree>
<drone-dji:GimbalPitchDegree>-5.50</drone-dji:GimbalPitchDegree>
<drone-dji:FlightRollDegree>+1.70</drone-dji:FlightRollDegree>
<drone-dji:FlightYawDegree>-113.60</drone-dji:FlightYawDegree>
<drone-dji:FlightPitchDegree>+0.00</drone-dji:FlightPitchDegree>

So as i read in other posts, it is near impossible to get this data in the right exif-tags.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Using Yaw Pitch Roll from DJI Drones
« Reply #1 on: February 24, 2016, 04:54:33 PM »
Hello doctorben,

In principle it is possible to use the Python code to read these values from the images. Can you send any single sample image with such embed data to support@agisoft.com to attach to the message, I'll try to post a script shortly that allows to read such values.
Best regards,
Alexey Pasumansky,
Agisoft LLC

doctorben

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Using Yaw Pitch Roll from DJI Drones
« Reply #2 on: February 24, 2016, 05:26:29 PM »
I've sent you a mail with an original image attached. 18MB rar-file. hope this works.
Thanks for the prompt support!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Using Yaw Pitch Roll from DJI Drones
« Reply #3 on: February 24, 2016, 05:55:23 PM »
Hello doctorben,

Here's a short script sample that reads the eight values that you mention from the DNG file and prints the read values to the Console pane for each camera in the active chunk:

Code: [Select]
import PhotoScan
from xml.dom import minidom

elements = ["drone-dji:AbsoluteAltitude=",
"drone-dji:RelativeAltitude=",
"drone-dji:GimbalRollDegree=",
"drone-dji:GimbalYawDegree=",
"drone-dji:GimbalPitchDegree=",
"drone-dji:FlightRollDegree=",
"drone-dji:FlightYawDegree=",
"drone-dji:FlightPitchDegree="]

chunk = PhotoScan.app.document.chunk

for camera in chunk.cameras:

path = camera.photo.path
with open(path, "rb") as file:
image = file.read()
string = str(image)
xmp_start = string.find('<x:xmpmeta')
xmp_end = string.find('</x:xmpmeta')
file.close()

if xmp_start != xmp_end:
xmpString = string[xmp_start : xmp_end + 12]

print(camera.label)
for element in elements:
value = string[string.find(element) + len(element) : string.find(element) + len(element) + 10]
value = float(value.split('\"',3)[1])
print(element, value)
print("\nScript finished")
Best regards,
Alexey Pasumansky,
Agisoft LLC

doctorben

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Using Yaw Pitch Roll from DJI Drones
« Reply #4 on: February 25, 2016, 10:08:27 AM »
Thank you Alexey for the quick work, the script doing it like a charm.
So my next question is, does it make sense to take the values into the camera-references (see picture).
Is there a potential benefit with this values before starting the alignment?
Like i read in other posts the yaw-value could help to get the right direction of the images taken on a planned mission flight path.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Using Yaw Pitch Roll from DJI Drones
« Reply #5 on: February 25, 2016, 10:55:12 AM »
Hello doctorben,

So you need to load Gimbal angles to the Reference pane?

Then just use
Code: [Select]
camera.reference.rotation = (yaw, pitch, roll)where yaw, pitch and roll values are read from the image header.

Best regards,
Alexey Pasumansky,
Agisoft LLC

mzaa

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Using Yaw Pitch Roll from DJI Drones
« Reply #6 on: February 29, 2016, 10:04:51 AM »
Can you compare the results?
With DJI data and with no data.

doctorben

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Using Yaw Pitch Roll from DJI Drones
« Reply #7 on: February 29, 2016, 05:35:27 PM »
In the screenshots you can see the alignment with and without imported angles.
So i think in this example, there is not a better result to get.
It is rather a benefit at very complexe shooting situations (several/ different photo-angles) where photoscan has problems to align the images (i think).
And whats more, that the compass is not the most accurate.

Perhaps Alexey can enlighten us about.

wizprod

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • Dronographica
Re: Using Yaw Pitch Roll from DJI Drones
« Reply #8 on: April 20, 2018, 02:42:52 PM »
Hello doctorben,

So you need to load Gimbal angles to the Reference pane?

Then just use
Code: [Select]
camera.reference.rotation = (yaw, pitch, roll)where yaw, pitch and roll values are read from the image header.

How do I relate to a specific imagefile, when using your script to extract the information?