Files
dodgeball-tracker/dodgeballtracker/typing.py
T

37 lines
809 B
Python

from typing import NewType
from dataclasses import dataclass
import numpy as np
XCoord = NewType('XCoord', float)
YCoord = NewType('YCoord', float)
Confidence = NewType('Confidence', float)
Category = NewType('Category', float)
@dataclass
class Point:
x: XCoord
y: YCoord
VideoFrame = NewType('Frame', float)
VideoTimestamp = float
@dataclass
class DetectedObject:
xmin: XCoord
ymin: YCoord
xmax: XCoord
ymax: YCoord
confidence: Confidence
category: Category
def as_int_box(self) -> tuple[tuple[int, int], tuple[int, int]]:
return (int(self.xmin), int(self.ymin)), (int(self.xmax), int(self.ymax))
def as_nparray(self):
return np.array([self.xmin, self.ymax, self.xmax, self.ymax, self.confidence, self.category])
Color = tuple[int, int, int]