start working with interpolation toggling
This commit is contained in:
@@ -48,6 +48,8 @@ class Marker:
|
||||
self.points = {}
|
||||
self.points_interpolated = {}
|
||||
self.point_index = None
|
||||
self.points_interpolation_enabled = True
|
||||
self.points_interpolation_required = False
|
||||
|
||||
self.message = None
|
||||
self.message_timer = time.time()
|
||||
@@ -254,7 +256,6 @@ class Marker:
|
||||
for index in self.points:
|
||||
if index == self.point_index and self.point_click == 1:
|
||||
continue
|
||||
|
||||
current = self.get_interpolated_point(index=index)
|
||||
if current["type"] in ("pre", "post"):
|
||||
continue
|
||||
@@ -313,10 +314,10 @@ class Marker:
|
||||
cv2.polylines(frame, [history], False, COLOR_INTERP, 1)
|
||||
|
||||
except KeyError:
|
||||
print(current, self.nr)
|
||||
print(self.get_interpolated_point(), self.nr)
|
||||
pass
|
||||
except IndexError:
|
||||
print(current, self.nr)
|
||||
print(self.get_interpolated_point(), self.nr)
|
||||
pass
|
||||
try:
|
||||
current = self.get_point()
|
||||
@@ -650,9 +651,12 @@ class World:
|
||||
post: after any keyframes
|
||||
"""
|
||||
|
||||
if self.points_interpolation_enabled:
|
||||
process = threading.Thread(target=self.interpolate_points_in_thread, args=(point_index,))
|
||||
process.start()
|
||||
|
||||
|
||||
|
||||
def interpolate_points_in_thread(self, point_index=None):
|
||||
|
||||
if point_index is None:
|
||||
@@ -670,6 +674,8 @@ class World:
|
||||
if not point_index in self.points_interpolated:
|
||||
self.points_interpolated[point_index] = {key: {} for key in range(self.frames)}
|
||||
|
||||
# ~ self.points_interpolation_required = False
|
||||
|
||||
new_points = {k: v for k, v in self.points_interpolated[point_index].items()}
|
||||
|
||||
if len(self.points[point_index]) == 1: # only one point added
|
||||
@@ -732,6 +738,12 @@ class World:
|
||||
|
||||
self.points_interpolated[point_index] = new_points
|
||||
|
||||
def toggle_interpolation(self):
|
||||
|
||||
self.points_interpolation_enabled = not self.points_interpolation_enabled
|
||||
if self.points_interpolation_enabled:
|
||||
self.interpolate_points()
|
||||
|
||||
def draw_help(self, frame):
|
||||
|
||||
bottom = 80
|
||||
@@ -832,6 +844,7 @@ class World:
|
||||
o toggle object is visible/occluded/hidden
|
||||
x toggle (delete) key frame
|
||||
r convert interpolated points to points (no undo!)
|
||||
u toggle automatic interpolation
|
||||
mouse left: set top-left corner of box
|
||||
mouse middle: set center of box
|
||||
mouse right: set lower right corner of box
|
||||
@@ -1322,7 +1335,8 @@ class World:
|
||||
self.track_point()
|
||||
elif k & 0xFF == ord("e"): # point edit (width height)
|
||||
self.modify_point_wh()
|
||||
|
||||
elif k & 0xFF == ord("u"): # toggle interpolation
|
||||
self.toggle_interpolation()
|
||||
elif k & 0xFF == ord("x"): # toggle ts
|
||||
if self.point_click == 1:
|
||||
self.toggle_point(self.nr)
|
||||
|
||||
Reference in New Issue
Block a user