简体   繁体   中英

extracting geographic coordinates from a smartphone photo

I want to extract the geopgraphic coordinates from a smartphone picture. All our photos are georeferenced and that info is embedded in headers somewhere. Is there a matlab or python function that can tell me a pictures geographic coordinates? I want to write a script which can calculate the distance between the two images, so if I can extract geographic coordinates of the two photos then I will be able to calculate the distance. thanks

If you want to use MATLAB, there is a function called imfinfo that extracts the exif data from an image file and saves it in a struct. You can find the GPS information in the GPSInfo field. Example:

info = imfinfo('filename.png');
info.GPSInfo

Then, to access the individual Latitude and Longitude values (expressed in degrees, minutes, seconds) you can check the fields GPSLatitude and GPSLongitude :

info.GPSInfo.GPSLatitude
info.GPSInfo.GPSLongitude

I would suggest looking into http://python-pillow.org

The following pillow documentation gives you are starting point to get what you are looking for.

https://pillow.readthedocs.io/en/latest/reference/ExifTags.html#exiftags-module

Are you allowed to use external tool?

Use jpegsnoop or exiftools to extract a txt file. I can't remember the exact commands but you can find it easily. Both tools have executables and code available. Personally, I like jpegsnoop better.

system('jpegsnoop.exe image/path ... output_image.txt);

Read the txt file which contains geo-tags. There might be up to 7 tags, different camera brands use different tags. Among those, will choose geolocation (I cant recall the exact name but it contains longitute and lattitude in the name).

You can do this by a simple while loop:

 while (line = readline) ~= EOF
      if line.startsWith (geo-tags)
             print line %or add to cell array etc.

To my experience, python is not as good as jpegsnoop .

As NaN mentioned, make sure the gps is on when you take the picture from the smart phone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM