Merge branch 'master' of git+ssh://git.six9.net:8222/moonq/tsmark

This commit is contained in:
q
2025-08-07 09:53:34 +03:00
2 changed files with 21 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ import argparse
from tsmark.video_annotator import Marker
VERSION = "0.7.1"
VERSION = "0.7.2"
def get_options():

View File

@@ -33,6 +33,7 @@ class Marker:
self.auto_step = True
self.font = cv2.FONT_HERSHEY_SIMPLEX
self.frame_visu = []
self.frame_raw = []
self.max_res = tuple([int(x) for x in self.opts.max_res.split("x")])
self.min_res = (512, None)
self.mouse_position = (0, 0)
@@ -860,12 +861,17 @@ class World:
else:
self.stamps = []
self.nr = 0
# Read boundinb boxes from JSON
# Read bounding boxes from JSON
if self.opts.input_points:
if os.path.exists(self.opts.input_points):
with open(self.opts.input_points, "rt") as fp:
self.points = json.load(fp)
for index in self.points:
keys = list(self.points.keys())
for index in keys:
# Remove empty dicts
if len(self.points[index])==0:
del self.points[index]
continue
self.point_index = index
self.points[index] = {int(k): v for k, v in self.points[index].items()}
for key in self.points[index]:
@@ -962,6 +968,8 @@ class World:
points[index][key]["x1"], points[index][key]["y1"] = self.visual_to_original(
(self.points[index][key]["x1"], self.points[index][key]["y1"])
)
if len(points[index]) == 0:
del points[index]
with open(self.opts.output_points, "wt") as fp:
json.dump(points, fp, indent=2)
@@ -1032,6 +1040,7 @@ class World:
show_time = time.time()
if (not self.paused) or self.read_next:
ret, frame = self.video_reader.read()
self.frame_raw = frame
if ret == True:
read_fails = 0
draw_wait = 200 if self.paused or (self.paused and self.point_click == 0) else 1
@@ -1039,6 +1048,7 @@ class World:
if (not self.paused) or self.read_next:
self.read_next = False
frame_visu = cv2.resize(frame.copy(), self.video_res)
self.frame_visu = frame_visu
self.draw_crop(frame_visu)
self.draw_points(frame_visu)
nr_time = self.nr / self.fps
@@ -1166,6 +1176,14 @@ class World:
2,
(255, 255, 255),
)
self.shadow_text(
frame_visu,
"Exists: " + "".join(sorted(self.points.keys())),
(20, 105),
0.8,
1,
(255, 255, 255),
)
cv2.imshow("tsmark", frame_visu)
k2 = cv2.waitKey(0)