Open NickMortimer opened 1 year ago
Here is some example code of using PyExifTool, which is a wrapper for ExifTool:
if os.path.exists(exif_data):
df_meta = pd.read_csv(exif_data)
print(f'Loaded {exif_data}')
else:
with exiftool.ExifTool() as et:
print('Parsing exif data')
metadata = et.execute_json(*tiffs)
df_meta = pd.DataFrame(metadata)
df_meta.to_csv(exif_data)
print(f'Exif data saved to {exif_data}')
wanted ={"SourceFile","FileModifyDate","ImageDescription",
"ExposureTime","FNumber","ExposureProgram","ISO",
"DateTimeOriginal","Make","SpeedX","SpeedY","SpeedZ",
"Pitch","Yaw","Roll","CameraPitch","CameraYaw","CameraRoll",
"ExifImageWidth","ExifImageHeight","SerialNumber",
"GPSLatitudeRef","GPSLongitudeRef","GPSAltitudeRef","AbsoluteAltitude",
"RelativeAltitude","GimbalRollDegree","GimbalYawDegree",
"GimbalPitchDegree","FlightRollDegree","FlightYawDegree",
"FlightPitchDegree","CamReverse","GimbalReverse","CalibratedFocalLength",
"CalibratedOpticalCenterX","CalibratedOpticalCenterY","ImageWidth",
"ImageHeight","GPSAltitude","GPSLatitude","GPSLongitude","CircleOfConfusion",
"FOV","Latitude",'Longitude','SubSecDateTimeOriginal','FlightYSpeed','FlightXSpeed','FlightYSpeed'
'Orientation','ShutterSpeedValue','ApertureValue','WhiteBalance','RtkFlag','DewarpData','DewarpFlag'}
def get_longitude(item):
longitude =float(item[0]) + float(item[2][0:-1])/60 + float(item[3][0:-1])/3600
return (longitude)
drone['Longitude'] = np.nan
drone['Latitude'] = np.nan
drone.loc[ ~drone['GPSLongitude'].isna(),'Longitude']=drone.loc[ ~drone['GPSLongitude'].isna(),'GPSLongitude'].str.split(' ',expand=True).apply(get_longitude,axis=1)
drone.loc[ ~drone['GPSLatitude'].isna(),'Latitude']=drone.loc[ ~drone['GPSLatitude'].isna(),'GPSLatitude'].str.split(' ',expand=True).apply(get_longitude,axis=1)
drone.loc[drone['GPSLatitudeRef']=='South','Latitude'] =drone.loc[drone['GPSLatitudeRef']=='South','Latitude']*-1
drone = drone[drone.columns[drone.columns.isin(wanted)]]
Run test data through existing scripts to extract the positions etc.