Skip to content

Instantly share code, notes, and snippets.

@masouduut94
Created July 10, 2020 08:13
Show Gist options
  • Save masouduut94/ca656512d76f8c633716cb003d04f723 to your computer and use it in GitHub Desktop.
Save masouduut94/ca656512d76f8c633716cb003d04f723 to your computer and use it in GitHub Desktop.
def bbox_exists(self, frame_id, bbox_id):
bboxes = []
if self.frame_exists(frame_id=frame_id):
bboxes = [bbox.bbox_id for bbox in self.frames[frame_id].bboxes]
return bbox_id in bboxes
def add_bbox_to_frame(self, frame_id: int, bbox_id: int, top: int, left: int, width: int, height: int):
if self.frame_exists(frame_id):
frame = self.frames[frame_id]
if not self.bbox_exists(frame_id, bbox_id):
frame.add_bbox(bbox_id, top, left, width, height)
else:
raise ValueError(
"frame with frame_id: {} already contains the bbox with id: {} ".format(frame_id, bbox_id))
else:
raise ValueError("frame with frame_id: {} does not exist".format(frame_id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment