def register(): openpifpaf.DATAMODULES['apollo'] = ApolloKp def initiate_json(self): """ Initiate json file: one for training phase and another one for validation. """ self.json_file["info"] = dict(url="https://github.com/vita-epfl/openpifpaf", date_created=time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime()), description="Conversion of ApolloCar3D dataset into MS-COCO format") self.json_file["categories"] = [dict(name='', # Category name id=1, # Id of category skeleton=[], # Skeleton connections (check constants.py) supercategory='', # Same as category if no supercategory keypoints=[])] # Keypoint names self.json_file["images"] = [] # Empty for initialization self.json_file["annotations"] = [] # Empty for initialization def process_image(json_file): """ Update image field in json file """ # ------------------ # Add here your code # ------------------- json_file["images"].append({ 'coco_url': "unknown", 'file_name': '', # Image name 'id': 0, # Image id 'license': 1, # License type 'date_captured': "unknown", 'width': 0, # Image width (pixels) 'height': 0}) # Image height (pixels) def process_annotation(json_file): """ Process and include in the json file a single annotation (instance) from a given image """ # ------------------ # Add here your code # ------------------- json_file["annotations"].append({ 'image_id': 0, # Image id 'category_id': 1, # Id of the category (like car or person) 'iscrowd': 0, # 1 to mask crowd regions, 0 if the annotation is not a crowd annotation 'id': 0, # Id of the annotations 'area': 0, # Bounding box area of the annotation (width*height) 'bbox': [], # Bounding box coordinates (x0, y0, width, heigth), where x0, y0 are the left corner 'num_keypoints': 0, # number of keypoints 'keypoints': [], # Flattened list of keypoints [x, y, visibility, x, y, visibility, .. ] 'segmentation': []}) # To add a segmentation of the annotation, empty otherwise