Agisoft Metashape

Agisoft Metashape => General => Topic started by: csherwood on January 23, 2017, 11:43:44 PM

Title: Altitude from EXIF in DJI Phantom 3 is negative
Post by: csherwood on January 23, 2017, 11:43:44 PM
The EXIF altidudes in the images (DJI Phantom 3 FC300X camera) have positive values; the values imported into Photoscan (Pro Windows 1.2.6 build 2843, 64 bit) are negative. Same numbers, but with a minus sign.

This is annoying, but the workaround is simple: export the camera locations, edit to remove the minus signs, and re-import...or use a script to scan the EXIF info in the images and generate the file to import, which may be preferable, because as others have pointed out, the actual values are off by some offset  that could be removed in the same script.

Camera info after loading photos in PhotoScan:
# CoordinateSystem: GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9102"]],AUTHORITY["EPSG","4326"]]
#Label,X/East,Y/North,Z/Altitude
DJI_0012.JPG,-70.486803,41.768299,-154.170000
DJI_0013.JPG,-70.486481,41.768133,-154.170000...

EXIF info as read by IrfanView (EXIF plugin):
Filename - DJI_0012.JPG
ImageDescription - DCIM\100MEDIA\DJI_0012.JPG
Make - DJI
Model - FC300X
Orientation - Top left
XResolution - 72
YResolution - 72
ResolutionUnit - Inch
Software - v01.30.5036
DateTime - 2017:01:09 12:48:27
...more info...
GPS information: -
GPSVersionID - 3.2.0.0
GPSLatitudeRef - N
GPSLatitude - 41  46  5.88 (41.768300)
GPSLongitudeRef - W
GPSLongitude - 70  29  12.49 (70.486803)
GPSAltitudeRef - Sea level reference
GPSAltitude - 154.17 m
Title: Re: Altitude from EXIF in DJI Phantom 3 is negative
Post by: Alexey Pasumansky on January 23, 2017, 11:56:58 PM
Hello csherwood,

Can you send any sample image file with the negative altitude to support@agisoft.com?
Title: Re: Altitude from EXIF in DJI Phantom 3 is negative
Post by: Alexey Pasumansky on January 24, 2017, 01:30:41 AM
Hello csherwood,

Exiftool utility shows that GPSAltitude is defined below sea level for the provided image.
Title: Re: Altitude from EXIF in DJI Phantom 3 is negative
Post by: Alexey Pasumansky on January 24, 2017, 03:54:03 PM
So it appears that the altitude is marked as Below Sea Level for the images, also the negative sign is observed for "Absolute Altitude  tag in the XMP header extension.

The script that reads "Relative Altitude" from XMP (I assume it's height above take off point) for all the cameras in the active chunk is the following:
Code: [Select]
import PhotoScan

doc = PhotoScan.app.document
chunk = doc.chunk

for camera in chunk.cameras:
if "DJI/RelativeAltitude" in camera.photo.meta.keys() and camera.reference.location:
z = float(camera.photo.meta["DJI/RelativeAltitude"])
camera.reference.location = (camera.reference.location.x, camera.reference.location.y, z)

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

And the script that adds the same value to camera heights in the active chunk is the following:
Code: [Select]
import PhotoScan

alt = PhotoScan.app.getFloat("Please specify the height in meters to be added:", 100)

doc = PhotoScan.app.document
chunk = doc.chunk

for camera in chunk.cameras:
if camera.reference.location:
coord = camera.reference.location
camera.reference.location = PhotoScan.Vector([coord[0], coord[1], coord[2] + alt])

chunk.updateTransform()
PhotoScan.app.update()
print("Script finished")
Title: Altitude error
Post by: FLEX on April 13, 2017, 05:42:43 PM
The elevation of my photo is 7.1452     The elevation of the software is -7.1452  why?Turn negative
Title: Re: Altitude error
Post by: Alexey Pasumansky on April 13, 2017, 05:44:26 PM
Hello FLEX,

I suggest to open the image in exiftool application and check if there's "Below sea level" mark. If it is there, then it should be corrected at side of camera and drone.

Title: Re: Altitude error
Post by: FLEX on April 13, 2017, 05:48:37 PM
(http://r.photo.store.qq.com/psb?/V11FTXaK27tCr4/4BaQss6RIF80V4sHvex9nwQtnQ*bMY5Zvws*7Rk87Lo!/o/dFYBAAAAAAAA&ek=1&kp=1&pt=0&bo=OwPSATsD0gEDCC0!&tm=1492092000&sce=0-12-12&rf=viewer_311)
Title: Re: Altitude error
Post by: Alexey Pasumansky on April 13, 2017, 05:55:31 PM
Hello FLEX,

Can you please attach any image from this set to the post?
Title: Re: Altitude error
Post by: Alexey Pasumansky on April 13, 2017, 06:01:39 PM
For me it looks like a DJI firmware issue, similar to the problem discussed on other forums:
http://forum.dev.dji.com/thread-31960-1-1.html
http://forum.dronedeploy.com/t/incorrect-exif-data-in-latest-dji-firmware-anyone-else-seen-this/1484

In another thread I've posted two scripts that can be used to read Relative Altitude from the image header and after that to add absolute altitude of the take-off point above ellipsoid:
http://www.agisoft.com/forum/index.php?topic=6405.0
Title: Re: Altitude error
Post by: FLEX on April 14, 2017, 05:05:54 AM
For me it looks like a DJI firmware issue, similar to the problem discussed on other forums:
http://forum.dev.dji.com/thread-31960-1-1.html
http://forum.dronedeploy.com/t/incorrect-exif-data-in-latest-dji-firmware-anyone-else-seen-this/1484
THANKS :) Solved my question
In another thread I've posted two scripts that can be used to read Relative Altitude from the image header and after that to add absolute altitude of the take-off point above ellipsoid:
http://www.agisoft.com/forum/index.php?topic=6405.0
Title: Re: Altitude from EXIF in DJI Phantom 3 is negative
Post by: mr map on November 20, 2018, 02:56:47 AM
Thank you for the add-altitude script, Alexey. Very useful, especially when using photos from DJI P4.
Title: Re: Altitude from EXIF in DJI Phantom 3 is negative
Post by: mcuske on February 16, 2019, 01:17:06 AM
I'm sorry Guys, but I'm not the expert in scripts. Could anyone explain in a very simple and transparent way how to run this script and what exactly do I have to do, step by step?:

import PhotoScan

alt = PhotoScan.app.getFloat("Please specify the height in meters to be added:", 100)

doc = PhotoScan.app.document
chunk = doc.chunk

for camera in chunk.cameras:
   if camera.reference.location:
      coord = camera.reference.location
      camera.reference.location = PhotoScan.Vector([coord[0], coord[1], coord[2] + alt])
   
chunk.updateTransform()
PhotoScan.app.update()
print("Script finished")
Title: Re: Altitude from EXIF in DJI Phantom 3 is negative
Post by: Alexey Pasumansky on February 16, 2019, 12:49:12 PM
Hello mcuske,

Save the script as .py file:
https://raw.githubusercontent.com/agisoft-llc/metashape-scripts/master/src/add_altitude_to_reference.py
Then use Run Script option in the Tools Menu and point to the .py file location.

It will add new menu item in Custom Menu, use it to open the dialog that would allow to add the fixed offset value to all altitude values for the cameras in the Reference pane.

P.S. Note that the script that I am referring to is for the version 1.5, but on Github you can also find the script version for PhotoScan Pro 1.4, if you are still using the older version.
Title: Re: Altitude from EXIF in DJI Phantom 3 is negative
Post by: mcuske on February 16, 2019, 02:37:12 PM
Thank You so much. It is working! :)