File size: 900 Bytes
07444d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
import os.path

from AbstractFileHandler import AbstractFileHandler

class IntermediateFile(AbstractFileHandler):

    def checkIfJsonExists(self, image_path):
        return os.path.isfile(super().changeFileExtension(image_path, "json"))
    
    def saveFileForCurrentImage(self, image_path, polygons):
        file_name = super().changeFileExtension(image_path, "json")
        with open(file_name, 'w') as file:
            json.dump(polygons, file)

    def loadFileForCurrentImage(self, image_path):
        file_name = super().changeFileExtension(image_path, "json")
        with open(file_name, 'r') as file:
            return json.load(file)

    def saveFile(self, filename, polygons):
        with open(filename, 'w') as file:
            json.dump(polygons, file)

    def loadFile(self, filename):
        with open(filename, 'w') as file:
            return json.load(file)