diff --git a/client/data/routines.py b/client/data/routines.py index b8531c8..0a4ff17 100644 --- a/client/data/routines.py +++ b/client/data/routines.py @@ -14,13 +14,27 @@ class User(NamedTuple): - """Represents a user record in the SQLite database""" + """Represents a user record in the SQLite database + + Attributes: + id_: Unique id for the user. Should be set to None when user does not exist in DB. + """ id_: Optional[int] class Posture(NamedTuple): - """Represents a posture record in the SQLite database""" + """Represents a posture record in the SQLite database + + Attributes: + id_: Unique id for the posture record. Should be set to None when record does not exist in + DB. + user_id: The user for which this posture applies to. + prop_good: Proportion of time the user is in the frame which the posture is good. + prop_in_frame: Proportion of time the user is in the frame during the period. + period_start: Start of the tracked period. + period_end: End of the tracked period. + """ id_: Optional[int] user_id: int @@ -85,7 +99,7 @@ def get_users(num: int = 10) -> list[User]: """ Args: num: Number of user to retrieve - + Returns: num users from the database. """ @@ -99,7 +113,7 @@ def get_postures(num: int = 10) -> list[Posture]: """ Args: num: Number of posture records to retrieve - + Returns: num posture records from the database. """ diff --git a/client/models/pose_detection/landmarking.py b/client/models/pose_detection/landmarking.py index 76c82b6..d272120 100644 --- a/client/models/pose_detection/landmarking.py +++ b/client/models/pose_detection/landmarking.py @@ -14,10 +14,13 @@ @dataclass class AnnotatedImage: - """Represents mutable annotated image through data attribute. + """Represents mutable annotated image container. Can be used to set annotated image within a callback asynchronously without raising an error. + + Attributes: + data: The actual image. """ data: Optional[np.ndarray] = None diff --git a/client/models/pose_detection/routines.py b/client/models/pose_detection/routines.py index 59e261f..fb167ac 100644 --- a/client/models/pose_detection/routines.py +++ b/client/models/pose_detection/routines.py @@ -25,7 +25,11 @@ class DebugPostureTracker(PoseLandmarker): - """Handles routines for a Debugging Posture Tracker""" + """Handles routines for a Debugging Posture Tracker. + + Attributes: + annotated_image: Mutable container for an image which may be mutated asynchronously. + """ def __init__( self, @@ -35,17 +39,17 @@ def __init__( ) -> None: super().__init__(graph_config, running_mode, packet_callback) self.annotated_image = AnnotatedImage() - self.video_capture = cv2.VideoCapture(0) + self._video_capture = cv2.VideoCapture(0) def track_posture(self) -> None: """Get frame from video capture device and process with pose model, then posture algorithm. Print debugging info and display landmark annotated frame. """ - success, frame = self.video_capture.read() + success, frame = self._video_capture.read() if not success: return - frame_timestamp_ms = self.video_capture.get(cv2.CAP_PROP_POS_MSEC) + frame_timestamp_ms = self._video_capture.get(cv2.CAP_PROP_POS_MSEC) mp_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=frame) self.detect_async(mp_image, int(frame_timestamp_ms)) @@ -54,7 +58,7 @@ def track_posture(self) -> None: cv2.imshow("output", self.annotated_image.data) def __exit__(self, unused_exc_type, unused_exc_value, unused_traceback) -> None: - self.video_capture.release() + self._video_capture.release() cv2.destroyAllWindows() super().__exit__(unused_exc_type, unused_exc_value, unused_traceback)