Beispiel #1
0
def get_geo_info(file_path):
    # Get the data from image file and return a dictionary
    data = gpsphoto.getGPSData(file_path)
    rawData = gpsphoto.getRawData(file_path)
    if 'Latitue' in data:
        return (data['Latitude'], data['Longitude'])
    else:
        return None
Beispiel #2
0
def main():
    orig_pic = '/Users/Leon/Documents/project/modPhotoGPS/data/IMG_0752.jpeg'
    print(os.path.exists(orig_pic))
    data = gpsphoto.getGPSData(orig_pic)
    rawdata = gpsphoto.getRawData(orig_pic)
    for tag in data.keys():
        print("%s: %s" % (tag, data[tag]))
    print("%s : %s" % (data['Latitude'], data['Longitude']))
    print("Hellps")
Beispiel #3
0
    def getData(self):
        data = gpsphoto.getGPSData(self.filepath)
        rawData = gpsphoto.getRawData(self.filepath)
        init.img_data[self.img] = {
        }  # create a new entry in the main dictionary with the image name as the key, and its value a new dictionary
        for tag in data.keys(
        ):  # for each of the extracted data pieces (lat, lon, alt)
            #print("%s: %s" % (tag, data[tag]))
            init.img_data[self.img][tag] = data[
                tag]  # supply the tag information to the dictionary
        #print("raw data")
        #for tag in rawData.keys(): # not necessary
        #print("%s: %s" % (tag, rawData[tag]))

        #print("img data") # for showing that the dictionary actually updated
        #print(init.img_data)
        return self.img  #return the image name
def main():
    """Calibrate images here"""
    args = get_args()
    img_list = glob.glob(f'{args.dir}/*.tif', recursive=True)
    out_path = args.outdir

    if not os.path.isdir(out_path):
        os.makedirs(out_path)

    for img in img_list:

        meta_path = img.replace('.tif', '_meta.csv')
        filename = os.path.basename(img)
        outfile = os.path.join(os.getcwd(), out_path, filename)
        print(outfile)

        meta_df = pd.read_csv(meta_path, delimiter=';')
        print(meta_df['TempFPA'][0])

        g_img = gdal.Open(img)
        exif_dict = piexif.load(img)
        zeroth = str(exif_dict['0th'])
        exif = str(exif_dict['Exif'])
        GPS = str(exif_dict['GPS'])

        gps_data = gpsphoto.getGPSData(img)
        rawData = gpsphoto.getRawData(img)

        raw_data = g_img.GetRasterBand(1).ReadAsArray().astype('float')
        tc = raw2temp(raw_data, meta_df)

        create_geotiff(tc, (0, 0, 0, 0), outfile, None, True, None,
            extra_metadata=[
                f'0th={str(zeroth.strip("{}"))}\n\
                Exif={str(exif.strip("{}"))}\n\
                GPS={str(GPS.strip("{}"))}\n'
            ], compress=False)

        cmd = f'exiftool -overwrite_original -TagsFromFile {img} {outfile}'
        subprocess.call(cmd, shell=True)

        exif_dict = piexif.load(outfile)
        gps_data = gpsphoto.getGPSData(outfile)
        print(f'{gps_data}\n')
Beispiel #5
0
def get_gps_info(img):
    imgPath = 'Images/2020/08/IMG_20200807_161158.jpg'
    data = gpsphoto.getGPSData(img)
    rawData = gpsphoto.getRawData(img)
    return data