oceanhackweek / ohw23_proj_drone_georef

We aim to develop a workflow to match drone images with a satellite grid
Apache License 2.0
1 stars 0 forks source link

Find ground control points in images #3

Closed NickMortimer closed 1 year ago

NickMortimer commented 1 year ago

Identify ground control points in the images. possibly using label me

https://github.com/NickMortimer/labelme

NickMortimer commented 1 year ago
    def strip_image(file):
        try:
            with open(file, "r") as read_file:
                data = json.load(read_file)
            if data.get('imageData'):
                data['imageData'] = None
                # Serializing json
                json_object = json.dumps(data, indent=2)
                # Writing to sample.json
                with open(file, "w") as outfile:
                    outfile.write(json_object)
                return {'file':file, 'Strip':'True'}
            return {'file':file, 'Strip':'False'}
        except:
            return {'file':file, 'Strip':'Bad'}

    def process_json(dependencies, targets):
         output = pd.DataFrame.from_records([strip_image(file) for file in dependencies])
         output.to_csv(targets[0])
NickMortimer commented 1 year ago

def loadshapes(file):
        print(file)
        lines =[]
        with open(file, "r") as read_file:
            data = json.load(read_file)

        #data = json.loads(''.join(lines).replace("\n", "").replace("'", '"').replace('u"', '"'))
        data =pd.DataFrame(data['shapes'])
        data['FilePath'] =file             
        return(data)

    def process_labelme(dependencies, targets):
        jsonfiles = glob.glob(os.path.join(os.path.dirname(targets[0]),'*.json'))
        if jsonfiles:
            data = pd.concat([loadshapes(file) for file in jsonfiles])
        else:
            data = pd.DataFrame()
        data.to_csv(targets[0],index=False)  
alsonathif commented 1 year ago

completed and added using labelme +code from above