version 0.7.14. fixing interpolator issues
This commit is contained in:
@@ -2,7 +2,7 @@ import argparse
|
||||
|
||||
from tsmark.video_annotator import Marker
|
||||
|
||||
VERSION = "0.7.13"
|
||||
VERSION = "0.7.14"
|
||||
|
||||
|
||||
class SmartFormatter(argparse.HelpFormatter):
|
||||
|
||||
@@ -814,7 +814,7 @@ class World:
|
||||
return True
|
||||
return False
|
||||
|
||||
def interpolate_set(self, point_index=None, nr=None):
|
||||
def interpolate_set(self, point_index=None, nr=None, refresh=False):
|
||||
|
||||
if point_index is None:
|
||||
point_index = self.point_index
|
||||
@@ -823,6 +823,11 @@ class World:
|
||||
if not point_index in self.points_interpolation_required:
|
||||
self.points_interpolation_required[point_index] = []
|
||||
self.points_interpolation_required[point_index].append(nr)
|
||||
if refresh:
|
||||
# refresh all points
|
||||
if point_index in self.points:
|
||||
self.points_interpolation_required[point_index].extend(list(self.points[point_index].keys()))
|
||||
|
||||
if not self.interpolate_thread_alive():
|
||||
print("ERROR: Interpolator thread is not running!")
|
||||
self.interpolate_thread_start()
|
||||
@@ -846,12 +851,6 @@ class World:
|
||||
def point2array(p):
|
||||
return [p["x0"], p["y0"], p["x1"], p["y1"]]
|
||||
|
||||
def tryadd(s, key, l):
|
||||
try:
|
||||
s.add(l[key])
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
if point_index in self.points_interpolation_required:
|
||||
seed_keys = (
|
||||
[x for x in self.points_interpolation_required[point_index]]
|
||||
@@ -881,35 +880,23 @@ class World:
|
||||
global_point_keys = list(sorted(list(self.points[point_index].keys())))
|
||||
|
||||
if len(seed_keys) > 0:
|
||||
point_keys = set()
|
||||
point_indexes = []
|
||||
min_seed = min(seed_keys)
|
||||
max_seed = max(seed_keys)
|
||||
min_found = False
|
||||
max_found = False
|
||||
first_seed = None
|
||||
for pi, nr in enumerate(global_point_keys):
|
||||
if not min_found:
|
||||
min_index = pi
|
||||
if not max_found:
|
||||
max_index = pi
|
||||
if nr >= min_seed:
|
||||
min_found = True
|
||||
if nr <= max_seed:
|
||||
tryadd(point_keys, pi, global_point_keys)
|
||||
|
||||
if nr >= min_seed and nr <= max_seed:
|
||||
point_indexes.append(pi)
|
||||
if nr > min_seed and first_seed is None:
|
||||
first_seed = pi
|
||||
point_indexes.append(pi)
|
||||
if nr > max_seed:
|
||||
max_found = True
|
||||
break
|
||||
if min_found:
|
||||
for shift in range(-3, 0):
|
||||
tryadd(point_keys, min_index + shift, global_point_keys)
|
||||
if max_found:
|
||||
for shift in range(2):
|
||||
tryadd(point_keys, max_index + shift, global_point_keys)
|
||||
else:
|
||||
for shift in range(-3, -1):
|
||||
tryadd(point_keys, len(global_point_keys) + shift, global_point_keys)
|
||||
|
||||
point_keys = list(sorted(list(point_keys)))
|
||||
if len(point_indexes) == 0:
|
||||
point_indexes.append(pi)
|
||||
min_index = max(0, min(point_indexes) - 3)
|
||||
max_index = min(len(global_point_keys) - 1, max(point_indexes) + 3)
|
||||
point_keys = [global_point_keys[pi] for pi in range(min_index, max_index + 1)]
|
||||
else:
|
||||
point_keys = global_point_keys
|
||||
|
||||
@@ -954,10 +941,10 @@ class World:
|
||||
new_points[key]["age"] = age
|
||||
|
||||
self.points_interpolated[point_index] = new_points
|
||||
if point_index in self.points_interpolation_required:
|
||||
self.points_interpolation_required[point_index] = [
|
||||
x for x in self.points_interpolation_required[point_index] if x not in seed_keys
|
||||
]
|
||||
if point_index in self.points_interpolation_required:
|
||||
self.points_interpolation_required[point_index] = [
|
||||
x for x in self.points_interpolation_required[point_index] if x not in seed_keys
|
||||
]
|
||||
except Exception as e:
|
||||
print(f"Interpolation error: {e}")
|
||||
|
||||
@@ -1251,7 +1238,7 @@ class World:
|
||||
)
|
||||
if not self.points[index][key].get("visible", "NA") in POINT_VISIBILITY:
|
||||
self.points[index][key]["visible"] = POINT_VISIBILITY[0]
|
||||
self.interpolate_set(index, key)
|
||||
self.interpolate_set(index, refresh=True)
|
||||
print(f"Loaded points with index: {index}")
|
||||
self.point_index = None
|
||||
|
||||
@@ -1563,6 +1550,7 @@ class World:
|
||||
self.point_click = 0
|
||||
else:
|
||||
self.point_index = chr(k2)
|
||||
self.interpolate_set(refresh=True)
|
||||
elif k & 0xFF == ord("g"): # Go to
|
||||
self.shadow_text(
|
||||
frame_visu,
|
||||
|
||||
Reference in New Issue
Block a user