简体   繁体   English

从智能手机照片中提取地理坐标

[英]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? 有matlab或python函数可以告诉我图片的地理坐标吗? 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. 如果要使用MATLAB,则有一个名为imfinfo的函数,该函数从图像文件中提取exif数据并将其保存在结构中。 You can find the GPS information in the GPSInfo field. 您可以在GPSInfo字段中找到GPS信息。 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 : 然后,要访问各个纬度和经度值(以度,分,秒表示),可以检查字段GPSLatitudeGPSLongitude

info.GPSInfo.GPSLatitude
info.GPSInfo.GPSLongitude

I would suggest looking into http://python-pillow.org 我建议调查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 https://pillow.readthedocs.io/zh_CN/latest/reference/ExifTags.html#exiftags-module

Are you allowed to use external tool? 您可以使用外部工具吗?

Use jpegsnoop or exiftools to extract a txt file. 使用jpegsnoopexiftools提取txt文件。 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. 我个人更喜欢jpegsnoop。

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

Read the txt file which contains geo-tags. 阅读包含地理位置标签的txt文件。 There might be up to 7 tags, different camera brands use different tags. 最多可能有7个标签,不同的相机品牌使用不同的标签。 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循环来做到这一点:

 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 . 以我的经验,python不如jpegsnoop

As NaN mentioned, make sure the gps is on when you take the picture from the smart phone. NaN所述,从智能手机拍摄照片时,请确保gps处于打开状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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