Setting compass direction to point to the next photo

Started by pussykatz, January 06, 2018, 02:57:04 PM

Previous topic - Next topic

pussykatz

Let's say that I mount a camera to my car, and I drive around while it's taking pictures continuously, and I also record my track with a GPS device.

Afterward, I should be able to use exiftool to geotag the photos based on the GPS log.

But what if I need to do an extra step of setting the compass heading on each photo, so that it's "pointing" to the next photo?

The math here should be really simple, since we have the location of each photo, and the camera is mounted to the car so its heading is consistent with the movement of the car. The camera may be pointing forward, sideways, or backward, so perhaps an offset is needed, but otherwise all the necessary information is there.

So how would I do this with exiftool, or is there an existing GUI that will do this for me?

pussykatz

I see that according to https://exiftool.org/geotag.html , exiftool will set GPSImgDirection if the information is available, so perhaps I can already do this without asking for a new feature from exiftool, but by preprocessing my GPS log and adding those compass heading for exiftool to simply copy.

If so, can you provide a brief .GPX example? Which .GPX tags are used by exiftool for GPSImgDirection?

Phil Harvey

ExifTool looks for the GPX "course" tag to get the image direction.  I can't get you a sample right now, but tomorrow when I have more time I could look for one.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Alan Clifford

There's a formula for the initial bearing along the great circle route between two points, on this website: https://www.movable-type.co.uk/scripts/latlong.html

Phil Harvey

Attached is a GPX sample which contains the "course" information for GPSImgDirection (as well as roll and pitch for the other two camera angles).  So with these three angles and the 3 coordinates (lat, lon and ele), the camera position and direction are fully defined.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

GPSmapper

Hi, I think it would be most appropriate to comment here, rather than creating a new topic.

Actually I am having the same question -
is it possible to "interpolate directions" when using geotag from gpx option in exiftool.

Case:

We have:
1. set of images without GPX tags  - we want to geotag them
2. GPX track which is MISSING course (heading) data
We want:
1. Use exiftool to geotag the images using gpx file
2. populate missing heading (GPSImgDirection, GPSImgDirtionRef) tags using "interpolation"
Logic of interpolation:
Straight-forward, there are some tools having this functionality, basically heading is interpolated based on each pair of 2 sequential points from gpx track.
So, if we have points 1,2,3,4,5
Heading for 1 is calculated based on GPScoord of points 1&2 - to make 1 point to 2 and so on.

Wonder if this functionality exists in exiftool (reading the above, I guess the answer is 'no)
Would the author consider adding such a functionality in the future?

Thanks!

Phil Harvey

I would definitely not just calculate the heading based on the difference between two adjacent GPS fixes -- the resulting heading would be vary wildly.  The proper way to do this is to first apply a Kalman filter to the track, then take the headings from the resulting smoothed track, but I think this type of processing is beyond the scope of ExifTool.  There are likely other GPS utilities that will do this given a GPX file.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

GPSmapper

ok, fair enough,
then another question,
one of the alternative programs I use to record the gpx track is Locus, which saves the course data in the file, but in slightly different format - see below (and attached).

Quote<trkpt lat="52.269324" lon="20.938925">
   <ele>138.00</ele>
   <time>2019-06-21T04:38:39.000Z</time>
   <pdop>3.22</pdop>
   <extensions>
      <gpxtpx:TrackPointExtension>
         <gpxtpx:course>291.5</gpxtpx:course>
      </gpxtpx:TrackPointExtension>
   </extensions>
</trkpt>

Does exiftool support this type of course flags?
If not, would it be a big deal to add this support?


Phil Harvey

ExifTool doesn't yet support this, but it should be easy to add.  I'll see about adding this feature.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

GPSmapper

Quote from: Phil Harvey on August 08, 2019, 09:57:55 PM
ExifTool doesn't yet support this, but it should be easy to add.  I'll see about adding this feature.
Thanks, Phil!
Looking forward to see this one day.  ::)
For now I can survive with notepad++ (regex search&replace)  :D

Phil Harvey

I was wrong.  I just tried your file and ExifTool already reads the course information.  But unfortunately it writes this to GPSImgDirection because the Arduino GPX tracks use the "course" tag for the camera direction.  But after geotagging, you can do this to move it to the GPSTrack if necessary:

exiftool "-gpstrack<gpsimgdirection" "-gpstrackref<gpsimgdirectionref" -gpsimgdirection= -gpsimgdirectionref= DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

GPSmapper

Quote from: Phil Harvey on August 09, 2019, 07:30:01 AM
it writes this to GPSImgDirection

In fact this is exactly what I need!

GPS Img Direction Ref           : True North
GPS Img Direction               : 46.89


I should have tried this myself prior to asking... ::)

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

7tonin

Quote from: Phil Harvey on August 08, 2019, 07:17:40 AMThere are likely other GPS utilities that will do this given a GPX file.
For instance, I'm using JOSM and two of its plugins in order to mass interpolate GPS image direction and adjust it for some pictures :
  • JOSM (Java OpenStreetMap Editor) is a desktop application for editing OpenStreetMap, the most powerful and complicated out of available editors.
    • Photo_Geotagging The plugin Photo Geotagging for JOSM is used correlate the GPS information of photos to a recorded track.
    • PhotoAdjust The photo adjust plugin allows to move geotagged photos on the map and to place photos that don't have GPS coordinates associated with them on the map, thus to geotag them.