KML Camera print format file help

Started by lifeofdave, September 24, 2012, 12:03:29 PM

Previous topic - Next topic

lifeofdave

Hi, I'm attempting to use embedded gps data inlcuding pitch and roll to create a KML file that contains a camera. The aim is to easily import photo overlays into google earth with the camera in the correct position.

I've looked through the example kml.fmt file provided with exiftool and understand well enough how it works. I can successfully create a kml file with the camera lat, long, and heading, however I'm having some trouble with pitch and roll as kml files use a different degree range to honeywell devices' $PTNTHPR sentences.

KML files (for google earth at least) have a tilt range of 0 - 360 degrees (at 0 camera looks straight down, 90 along horizon, 180 straight up), whereas PTNTHPR sentences have a range of -90 to +90 degrees (-90 looking down, +90 up).

Is there a way to evaluate arithmetic in the .fmt file to adjust the pitch range for google earth or would exiftool code have to be changed to achieve this? I've played around trying to add 90 to pitch within the fmt code but had no luck.

Here is the partially working <Camera> part of the fmt file as it stands.

#[BODY] <Camera>
#[BODY] <longitude>$gpslongitude#</longitude>
#[BODY] <latitude>$gpslatitude#</latitude>
#[BODY] <altitude>0</altitude>
#[BODY] <heading>$gpsimgdirection#</heading>
#[BODY] <tilt>$gpspitch#</tilt>
#[BODY] <roll>$gpsroll#</roll>
#[BODY] <gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
#[BODY] </Camera>


Somehow that all got quite long winded for what is a simple questions in my mind! Thanks in advance for any suggestions.

Dave

Phil Harvey

Hi Dave,

Any conversion like this is done through a user-defined Composite tag:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyTilt => {
            Require => 'GPSPitch',
            ValueConv => '$val + 90',
        },
    },
    'Image::ExifTool::GPS::Main' => {
        0xd000 => {
            Name => 'GPSPitch',
            Writable => 'rational64s',
        },
        0xd001 => {
            Name => 'GPSRoll',
            Writable => 'rational64s',
        },
    },
);
1; # end


Then use $mytilt in your format file.

Sounds like you're into underwater surveying.  Once upon a time I worked for a sonar company and wrote some software to display sonar images, including use of the towfish position and attitude for proper mapping of the images.

- 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 ($).

lifeofdave

Nice, thought there had to be an elegant solution!

Not quite doing underwater surveying though, the 'relativeToSeaFloor' is something I selected by accident in google earth.  :)

Once again, thanks for your help.