Agisoft Metashape

Agisoft Metashape => General => Topic started by: nanders on July 03, 2014, 02:45:36 PM

Title: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: nanders on July 03, 2014, 02:45:36 PM
Hi all,

I noticed one can import GPS and orientation data from the EXIF metadata in the images.

I have Roll, Pitch and Yaw data of my (UAV-based) images in a separate csv file, but I can't find where to store it in the EXIF data so that PhotoScan is able to import it.

anyone can help me with this?
thanks!

Niels
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Alexey Pasumansky on July 03, 2014, 04:20:20 PM
Hello Niels,

You can check EXIF 2.3 standard specification:
http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: nanders on July 03, 2014, 05:33:37 PM
thank you for your reply.

from that document I learn that there is a tag called GPSImgDirection which contains information about the direction (yaw), also mentioned in the exiftool documentation (http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/index.html) and here on the forum (http://www.agisoft.ru/forum/index.php?topic=2416.msg12846#msg12846).

From the latter forum post I also learned there should be support for GPSRoll and GPSPitch tags in the EXIF structure. I guess my images (from Panasonic GX1) don't support these GPSRoll and GPSPitch tags (exiftool mentions there are no such tags), and data in GPSImgDirection doesn't get imported into PhotoScan.

I guess the easiest workaround for me right now is to hack the xml of the psz files and include the attitude info there.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: ozbigben on July 04, 2014, 01:00:13 AM
You could try using EXIFTool to format the EXIF data from the images e.g. http://www.sno.phy.queensu.ca/~phil/exiftool/geotag.html#Inverse (http://www.sno.phy.queensu.ca/~phil/exiftool/geotag.html#Inverse)
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: nanders on July 04, 2014, 10:05:28 AM
Thanks, I will look into that!
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: ozbigben on July 04, 2014, 12:04:48 PM
Forgot to mention that one of the good things about Exiftool id that even though it may not be able to write a specific tag, it will extract any metadata it can find in an image. I use:
Code: [Select]
exiftool -s %1 > metadata.txtfor a drag and drop batch file to list the available metadata in an image into a text file. When you're setting up your format file just take the field names from this and prefix them with "$" wherever you want a field value written.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: MK on July 04, 2014, 06:00:13 PM
Correct me if i'm wrong, but does Photoscan uses roll/pitch/yaw? Then whats the point of such data import?
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: nanders on July 08, 2014, 03:53:27 PM
I wasn't able to import attitude data from exif tags, so I generated the xml code myself and zipped it to create a psz project file. Now attitude data is included.

@mk_horus: PS shows measured and predicted yaw/pitch/roll so I assume it also uses these parameters for camera alignment. See screenshot:

(http://www.nielsanders.nl/forumpics/attitude.PNG)
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Alexey Pasumansky on July 08, 2014, 04:04:40 PM
Hello Niels,

Error values are the difference between source (that you've input) and estimated by PhotoScan. Source values are still not used during Align Photos stage.

And wasn't that easier to generate a plain text file with camera labels, positions and orientation angles and import it using the corresponding button on the Ground Control pane?
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: nanders on July 08, 2014, 04:17:14 PM
oh okey, so yaw/pitch/roll values does not influence accuracy of the alignment, I wasn't sure.
How about altitude? is that also not taking into account in the camera alignment phase?

I assumed the files with ground control should contain new cameras, instead of already imported cameras. Now I think of it a bit longer the ground control files are indeed used to describe the existing photos. I guess you're right that is easier (not that the xml was really hard) and more straightforward.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Alexey Pasumansky on July 08, 2014, 04:19:26 PM
PhotoScan uses camera position information during Align Photos stage to reduce the processing time by matching only those cameras, that are overlapping according to the Ground Control pane information (searching in some radius).
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: andrekje on May 16, 2016, 11:46:46 PM
please post a properly geotagged photo (with pitch/roll/yaw )   - as I had no success finding the exif tags Photoscan pro is  reading to get those values.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Alexey Pasumansky on May 17, 2016, 01:38:27 PM
Hello andrekje,

PhotoScan reads the following EXIF tags:
GPSLatitudeRef
GPSLatitude
GPSLongitudeRef
GPSLongitude
GPSAltitudeRef
GPSAltitude

If you need to load the orientation angle information as well, you can use Python scripting for custom data import from the image header.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: andrekje on May 17, 2016, 02:04:13 PM
So, pitch, roll, yaw is not imported automatically from exif when adding photos, an script is needed ?
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Alexey Pasumansky on May 17, 2016, 02:13:05 PM
According to the EXIF 2.3 standard there are no fields dedicated to the yaw/pitch/roll angles:
http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf

It means that in case the data is saved in some other fields or header extensions, a custom script is required to read it.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: andrekje on May 17, 2016, 02:16:40 PM
Yes, I just hoped you invented some names, that were read if existing.
That would save a step.
Is there an example script that does it ?
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Alexey Pasumansky on May 17, 2016, 02:25:15 PM
An example of reading orientation angles from the DJI xmp-extension is given here:
http://www.agisoft.com/forum/index.php?topic=5008

But since the data can be saved anywhere, there's no script that will work in any cases, as it should be based on the format of the input data.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: andrekje on May 17, 2016, 03:43:36 PM
Thank you.
The reason I am asking, is not to save processing power, it's because I had some flights in very strong winds where plane had to crosstrack at 70degree yaw to keep the planned pattern.
Of course, that reduced overlap significantly,  and resulted in a bunch of holes.

(the photos were aligned by reference)

Do you know wherever adding yaw data would help at all, or an modified/different method of alignment would better find matching points ?

Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Alexey Pasumansky on June 13, 2016, 09:29:20 PM
Hello andrekje,

Version 1.2.5 should allow to load the camera orientation angles defined using XMP image header extension. You need to check on the corresponding option in the Preferences window first, before using Import EXIF option.
If you have any issues with that, please provide image sample to us.

Angle orientation information may help, if the data is accurate. Also it may help for Reference preselection option when oblique aeiral images are processed.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Paulo on June 13, 2016, 11:31:07 PM
Dear Alexey,

with latest version, I am trying to read yaw, pitch and roll activating the Load camera orientation angles from XMP meta data option in Advanced Preferences and it fails for the following image (see attachment for exif data read with Exif Tool).

With Exif Tool, i can see that it has following XMP entries:

---- XMP-Camera ----
GPSXY Accuracy                  : 6.571000099182129
GPSZ Accuracy                   : 5.468999862670898
Pitch                           : 3.630061864852905
Roll                            : 2.026665210723877
Yaw                             : 265.078704833984375

What would be the cause?

Regards,
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Dmitry Semyonov on June 14, 2016, 11:25:33 AM
Hello pap1956,

Unfortunately Camera orientation from XMP currently doesn't support Sensefly produced images. Can you please send a sample image to support@agisoft.com so that we can make sure it is included in the next update? Exif Tool output provided is not sufficient for implementation.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Paulo on June 14, 2016, 08:17:04 PM
Thanks Dmitry,

have sent to support sample images from both Sensefly eBee and Phantom2 Vision FC200 that have same problem .
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Dmitry Semyonov on June 14, 2016, 09:14:34 PM
Hello pap1956,

Thanks for providing sample images, support for both XMP variants will be added in the next update.
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: jmos on June 24, 2017, 10:40:27 AM
Hi, would also like to use orientation data to improve referencing.
Currently using Hasselblad camera and OXTS RT-3042 IMU.

Would be good to hear about different results.

John
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: harrytwomey on April 17, 2019, 11:47:02 AM
hi could you possible have an example script, thatwe could change the vairable to match the values in our exif, we would like to import yaw pitch roll, also xy accuracy and z accuracy
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: harrytwomey on April 17, 2019, 01:07:35 PM
i think i did it

Code: [Select]
# Script to add exif for SODA Meta data for all cameras in the active chunk.

import PhotoScan

# Checking compatibility
compatible_major_version = "1.4"
found_major_version = ".".join(PhotoScan.app.version.split('.')[:2])
if found_major_version != compatible_major_version:
    raise Exception("Incompatible PhotoScan version: {} != {}".format(found_major_version, compatible_major_version))

def sodaADD():
"""
Reads Soda/accuracy/YPR
"""
doc = PhotoScan.app.document
if not len(doc.chunks):
raise Exception("No chunks!")
print("Script started...")
chunk = doc.chunk

for camera in chunk.cameras:
vect = PhotoScan.Vector((10, 10, 10))
locationAccuracy = PhotoScan.Vector((10, 10, 10))
if 'Sensefly/Yaw' in camera.photo.meta.keys():
vect[0] = float(camera.photo.meta["Sensefly/Yaw"])
if 'Sensefly/Pitch' in camera.photo.meta.keys():
vect[1] = float(camera.photo.meta["Sensefly/Pitch"])
if 'Sensefly/Roll' in camera.photo.meta.keys():
vect[2] = float(camera.photo.meta["Sensefly/Roll"])

print(vect)

if 'Sensefly/GPSXYAccuracy' in camera.photo.meta.keys():
locationAccuracy[0] = float(camera.photo.meta["Sensefly/GPSXYAccuracy"])
if 'Sensefly/GPSXYAccuracy' in camera.photo.meta.keys():
locationAccuracy[1] = float(camera.photo.meta["Sensefly/GPSXYAccuracy"])
if 'Sensefly/GPSZAccuracy' in camera.photo.meta.keys():
locationAccuracy[2] = float(camera.photo.meta["Sensefly/GPSZAccuracy"])

print(locationAccuracy)

camera.reference.rotation = vect
camera.reference.location_accuracy = locationAccuracy

chunk.updateTransform()
PhotoScan.app.update()
print("Script finished")

label = "Custom menu/Add S.O.D.A Exif Data"
PhotoScan.app.addMenuItem(label, sodaADD)
print("To execute this script press {}".format(label))
Title: Re: Where to store Roll Pitch Yaw data in EXIF for import into PS
Post by: Alexey Pasumansky on April 17, 2019, 01:36:22 PM
Hello harrytwomey,

Aren't these values loaded automatically to the Reference pane, if you enable "Load Camera Orientation Angles from XMP meta" and "Load Camera Location Accuracy from XMP meta" in the Advanced Preferences tab?
I think they were supported already in PhotoScan Pro 1.4.5.