Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added method docs to Auto Annotation inference.py #725

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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