Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Use perl to extract GPS coordinates from a cell phone image.

by Anonymous Monk
on Jan 02, 2013 at 06:58 UTC ( #1011215=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks.

I am quite interested in using perl (ideally) to extract GPS coordinates embedded in an image taken with a modern cell phone camera. I have started writing such a (fledgling) application (see below) but I was wondering if there was a convenient way to transform the binary data into a more "user friendly", i.e., readable, format? Perhaps using pack?

use warnings; use strict; my $file; my $data; print "Please enter the file name: "; chomp($file = <STDIN>); open IMG, $file or die "Error : $!\n"; binmode IMG; $data = do{local $/; <IMG>}; close IMG, $file or die "Error : $!\n";


Thanks.

Comment on Use perl to extract GPS coordinates from a cell phone image.
Download Code
Re: Use perl to extract GPS coordinates from a cell phone image.
by Anonymous Monk on Jan 02, 2013 at 07:08 UTC

    Um, no.

    The way to extract blahblah data from an image, is to determine if it is metadata or pixels.

    If it is metadata, get metadata image format module

    If it is pixels, forget about it :) Re: image shape processing

Re: Use perl to extract GPS coordinates from a cell phone image.
by tobyink (Abbot) on Jan 02, 2013 at 07:20 UTC
    use 5.010; use strict; use warnings; use Image::ExifTool ':Public'; my $filename = "MyImage.jpeg"; my $metadata = ImageInfo $filename; say "Latitude: ", $metadata->{GPSLatitude}; say "Longitude: ", $metadata->{GPSLongitude}; say "Altitude: ", $metadata->{GPSAltitude}; say "DateTime: ", $metadata->{GPSDateTime};

    Works for my phone; different phones may set different EXIF keys, so you may need to experiment a little.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      Hello tobyink,

      ++ for a great response. I have tried using your sample script and everything works great, except I have yet to see GPS data results. I reread the CPAN docs for 'Image::ExifTool' and it references a config file and was wondering if you had defined a config file?

      I'm using a LG LS670 phone camera with GPS on, as well as checking some apple camera pictures that show GPS info. (Friend sent pictures to me, so I hope the pictures actually have the GPS info embedded).

      Any ideas appreciated.

      Thank you...Ed

      "Well done is better than well said." - Benjamin Franklin

        Works out of the box for me. (HTC Explorer phone, Android 2.3.)

        You could try throwing $metadata at Data::Dumper to see what's inside...

        use Data::Dumper; print Dumper ImageInfo "MyImage.jpeg";
        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Use perl to extract GPS coordinates from a cell phone image.
by flexvault (Parson) on Jan 07, 2013 at 18:26 UTC

    Dear Monks,

    As a follow up to my previous questions and to possibly help someone else in the future. On my cell phone, LG LS670, in camera mode it has a hidden button to toggle ON/OFF the 'store location' setting which is the GPS information.

    If works great now!

    Thanks...Ed

    "Well done is better than well said." - Benjamin Franklin

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011215]
Approved by tobyink
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-07-25 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls