如何使用文本文件中的经度和纬度对图像进行地理标记?

时间:2019-03-23 10:29:15

标签: python image gps exiftool

我有一个摄像头是用连接到无人机的摄像头捕获的。我使用的相机无法提供任何GPS数据,但是,无人机具有内置的GPS,可以用来获取捕获图像的位置。我将此信息保存在一个文本文件中。如何将文本文件中保存的纬度和经度添加到图像中?我正在用python编写代码。到目前为止,我只发现了有关通过exiftool使用csv或gpx文件的信息,而没有有关文本文件的信息。

1 个答案:

答案 0 :(得分:2)

import exiftool

et = exiftool.ExifTool("C:\Users\...\exiftool.exe")
et.execute("-GPSLongitude=10.0", "picture.jpg")
et.execute("-GPSLatitude=5.78", "picture.jpg")
et.execute("-GPSAltitude=100", "picture.jpg")
et.terminate()

并且不使用terminate()语句

with exiftool.ExifTool("C:\Users\...\exiftool.exe") as et:
    et.execute("-GPSLongitude=10.0", "picture.jpg")
    et.execute("-GPSLatitude=5.78", "picture.jpg")
    et.execute("-GPSAltitude=100", "picture.jpg")

用户@StarGeek也说

  

您还必须设置GPSLatitudeRef和GPSLongitudeRef值,   特别是在西半球或南半球时。它   可以用et.execute(“-GPSLongitudeRef = 10.0”,   “ picture.jpg”)– StarGeek

相关问题