Skip to content

Commit

Permalink
added method docs to Auto Annotation inference.py (cvat-ai#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoff authored and Chris Lee-Messer committed Mar 5, 2020
1 parent 0104462 commit d2cf168
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions cvat/apps/auto_annotation/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ def __init__(self):
"tracks": []
}

def add_box(self, xtl, ytl, xbr, ybr, label, frame_number, attributes=None):
# https://stackoverflow.com/a/50928627/2701402
def add_box(self, xtl: float, ytl: float, xbr: float, ybr: float, label: int, frame_number: int, attributes: dict=None):
"""
xtl - x coordinate, top left
ytl - y coordinate, top left
xbr - x coordinate, bottom right
ybr - y coordinate, bottom right
"""
self.get_shapes().append({
"label": label,
"frame": frame_number,
Expand All @@ -47,17 +54,17 @@ def add_box(self, xtl, ytl, xbr, ybr, label, frame_number, attributes=None):
"attributes": attributes or {},
})

def add_points(self, points, label, frame_number, attributes=None):
def add_points(self, points: list, label: int, frame_number: int, attributes: dict=None):
points = self._create_polyshape(points, label, frame_number, attributes)
points["type"] = "points"
self.get_shapes().append(points)

def add_polygon(self, points, label, frame_number, attributes=None):
def add_polygon(self, points: list, label: int, frame_number: int, attributes: dict=None):
polygon = self._create_polyshape(points, label, frame_number, attributes)
polygon["type"] = "polygon"
self.get_shapes().append(polygon)

def add_polyline(self, points, label, frame_number, attributes=None):
def add_polyline(self, points: list, label: int, frame_number: int, attributes: dict=None):
polyline = self._create_polyshape(points, label, frame_number, attributes)
polyline["type"] = "polyline"
self.get_shapes().append(polyline)
Expand All @@ -69,7 +76,7 @@ def get_tracks(self):
return self._results["tracks"]

@staticmethod
def _create_polyshape(points, label, frame_number, attributes=None):
def _create_polyshape(points: list, label: int, frame_number: int, attributes: dict=None):
return {
"label": label,
"frame": frame_number,
Expand Down

0 comments on commit d2cf168

Please sign in to comment.