[Elphel-support] Elphel camera on the Global Hawk

Andrey Filippov andrey at elphel.com
Mon Apr 19 16:41:59 PDT 2010


Scott,

There is no easy way to write GPS data to Exif bypassing the program in C
that does it. The Elphel PHP extension includes parsing Exif data into human
readable form, but not the other way around.

Internally camera maintains condensed Exif - "condensed" is what remains
from the Exif header if you remove all the constant fields (like camera
model) and the Exif pointers and merge the remaining fields together. These
condensed Exif headers are copied from the "current" data buffer for each
frame that is stored in the output video buffer so the Exif data can be
re-assembled with the images when applications read them from the circular
video buffer.

When application (such as camogm, streamer or imgsrv) reads image frame and
requests Exif header that dynamic data (individual for each acquired frame)
is combined with the static template (generated at boot time) and provided
to an application as complete Exif header.

The php script that runs at startup:

http://elphel.cvs.sourceforge.net/viewvc/elphel/elphel353-8.0/apps/web/imgsrv/exif.php?view=markup

creates template from the XML file

http://elphel.cvs.sourceforge.net/viewvc/elphel/elphel353-8.0/apps/web/imgsrv/Exif_template.xml?view=markup

and builds the directory for the condensed Exif writable by the
applications. This directory does not include the data format of the
particular Exif fields - just the offset and length (in bytes) fo that
field, referenced by the modified Exif tag number (modified to include both
tag number and tag group in a single long number). It is up to the
particular application to format data according to Exif conventions and
matching the Exif_template.xml

Example of the PHP script


http://elphel.cvs.sourceforge.net/viewvc/elphel/elphel353-8.0/packages/web/353/camvc/camvc.php?view=markup

 343               if ( $value!==null)  elphel_set_exif_field(0x10e,
$value.chr(0));

writes string data from $value terminated by zero byte (chr(0) ) to Exif
field with the tag 0x10e (group 0) , the tag called "ImageDescription" in
Exif. The Exif_template.xml reserves 40 bytes fro the image description, so
if you need more you have to modify that template file. It is also possible
to add more fileds - you need to define them in Exif_template.xml, then
write with elphel_set_exif_field (or directly using the device driver).

It should be possible to write GPS data fileds with PHP script, but that
would be more tricky than to wrikte to ImageDescription tag - you'll need to
write data in the Exif format, not just string data. Making all such
conversions in PHP may add considerable load if the data is updated at high
rate,  you may need to write a C program, modifying it from this one:

http://elphel.cvs.sourceforge.net/viewvc/elphel/elphel353-8.0/apps/garminusb2nmea-0.12a/nmea2exif.c?view=markup

So the quick fix that I would recommend is to format the required data into
a string of <=40 bytes and use elphel_set_exif_field(0x10e,
$string_to_write.chr(0));

Andrey


On Mon, Apr 19, 2010 at 4:32 PM, Andrey Filippov <andrey at elphel.com> wrote:

> Scott,
>
> is it OK to reply you through the mailing list? This topic may be of
> interest to other users.
>
> Andrey
>
>
> On Mon, Apr 19, 2010 at 3:37 PM, Scott Janz <scott.janz at nasa.gov> wrote:
>
>> Hello Andrey,
>>
>> I'm sorry I'm not very good with PHP and need a little more info, this is
>> the way I currently read the GPS data from the EXIF header via PHP
>>
>> #!/usr/local/sbin/php -q
>> <?php
>> $exif=elphel_get_exif_elphel('0');
>> echo
>> "EXIF:",$exif['GPSDateTime'],",",$exif['GPSLatitude'],",",$exif['GPSLongitude'],",",$exif['GPSAltitude'],";
>> ?>
>>
>> How exactly do I write my own values back? What does the 0x10e signify?
>>
>>
>> thanks,
>>
>> -scott
>>
>>
>> Andrey Filippov wrote:
>>
>>> Scott,
>>>
>>> you may try that, the easiest thing would be to write to image
>>> description (it is set with 40 bytes length, similarly to:
>>>
>>>
>>> http://elphel.cvs.sourceforge.net/viewvc/elphel/elphel353-8.0/packages/web/353/camvc/camvc.php?view=markup
>>>  342             case "description":
>>>  343               if ( $value!==null)  elphel_set_exif_field(0x10e,
>>> $value.chr(0));
>>>
>>>  344               break;
>>> You may do the same with the GPS fileds, but that may be slower and eat
>>> up to much of the CPU resources. The data you write to Exif should be
>>> already formatted in the same way as it is stored in Exif).
>>>
>>> When you write to any of these fields, the data will be applied to all
>>> the next frames until overwritten.
>>>
>>> Andrey
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://support.elphel.com/pipermail/support-list_support.elphel.com/attachments/20100419/d70cd356/attachment-0002.html>


More information about the Support-list mailing list