diff --git a/tsmark/video_annotator.py b/tsmark/video_annotator.py index 12b35b9..a5b9326 100755 --- a/tsmark/video_annotator.py +++ b/tsmark/video_annotator.py @@ -380,7 +380,7 @@ class Marker: "y0": ip["y0"], "x1": ip["x1"], "y1": ip["y1"], - "visible": POINT_VISIBILITY[0], + "visible": ip["visible"], } self.points_interpolation_required[self.point_index] = True except Exception: @@ -474,7 +474,6 @@ class Marker: "y1": ip["y1"], "visible": POINT_VISIBILITY[0], } - # self.interpolate_points() def modify_point(self, position, x, y): """position: tl topleft, br bottomright, c center""" @@ -507,7 +506,7 @@ class Marker: "y0": y, "x1": min(self.video_res[0] - 1, x + w), "y1": min(self.video_res[1] - 1, y + h), - "visible": POINT_VISIBILITY[0], + "visible": last_p["visible"], } if position == "br": self.points[self.point_index][self.nr] = { @@ -515,7 +514,7 @@ class Marker: "y0": max(0, y - h), "x1": x, "y1": y, - "visible": POINT_VISIBILITY[0], + "visible": last_p["visible"], } if position == "c": self.points[self.point_index][self.nr] = { @@ -523,12 +522,11 @@ class Marker: "y0": max(0, int(y - h / 2)), "x1": min(self.video_res[0] - 1, int(x + w / 2)), "y1": min(self.video_res[1] - 1, int(y + h / 2)), - "visible": POINT_VISIBILITY[0], + "visible": last_p["visible"], } else: # not a new point - self.points[self.point_index][self.nr]["visible"] = POINT_VISIBILITY[0] if position == "c": current = self.points[self.point_index][self.nr] w = abs(current["x1"] - current["x0"]) @@ -538,7 +536,7 @@ class Marker: "y0": max(0, int(y - h / 2)), "x1": min(self.video_res[0] - 1, int(x + w / 2)), "y1": min(self.video_res[1] - 1, int(y + h / 2)), - "visible": POINT_VISIBILITY[0], + "visible": current["visible"], } elif position == "tl": self.points[self.point_index][self.nr]["x0"] = x @@ -1485,6 +1483,7 @@ class TrackerGUI: ok, frame = self.marker.video_reader.read() frame = cv2.resize(frame.copy(), self.marker.video_res) bbox = tuple([curr_point["x0"], curr_point["y0"], curr_point["w"], curr_point["h"]]) + bbox_area = curr_point["w"] * curr_point["h"] ok = tracker.init(frame, bbox) visu_interval = 0.2 show_time = 0 @@ -1507,10 +1506,10 @@ class TrackerGUI: point = self.marker.get_point(nr=self.marker.nr + i) bbox = tuple([point["x0"], point["y0"], point["w"], point["h"]]) tracked[i] = [*bbox, 1] - show_message = f"Tracking... ({i}/{max_frames})" + show_message = f"Tracking... ({i+1}/{max_frames})" else: # Tracking failure - show_message = f"Tracking failure detected ({i}/{max_frames})" + show_message = f"Tracking failure detected ({i+1}/{max_frames})" bbox = None if time.time() > show_time + visu_interval: @@ -1598,12 +1597,14 @@ class TrackerGUI: for i in sorted(list(tracked.keys())): if i >= cut_after: continue + track_area = tracked[i][2] * tracked[i][3] + visibility = POINT_VISIBILITY[0] if track_area > 0.9 * bbox_area else POINT_VISIBILITY[1] self.points[old_nr + i] = { "x0": tracked[i][0], "y0": tracked[i][1], "x1": tracked[i][0] + tracked[i][2], "y1": tracked[i][1] + tracked[i][3], - "visible": POINT_VISIBILITY[0], + "visible": visibility, } self.marker.nr = old_nr + cut_after - 1