Skip to content

Commit 7bd8bd6

Browse files
author
arch
committed
change interpolation
1 parent ce6e6dd commit 7bd8bd6

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ def interpolate_bboxes(self, bboxes :dict) -> dict:
128128
Returns:
129129
dict: interpolated bboxes {'Men': {tracker_number: [(box_frame1),(box_frame2),....], ...} 'Woman': {tracker_number: [(box_frame1),(box_frame2),....], ...}}
130130
"""
131+
interpolation = 'quadratic'
132+
if self.params.supervised_tracking and not self.params.supervised_tracking_is_exit_condition:
133+
# NOTE: wh have to use linea interpolation to get flat lines at when the feature leave the tracking area
134+
interpolation = 'linear'
135+
136+
self.logger.info("Use %s interpolation", interpolation)
137+
131138
interpolated_bboxes = {}
132139
for tracker_type in bboxes:
133140
interpolated_bboxes[tracker_type] = {}
@@ -144,10 +151,10 @@ def interpolate_bboxes(self, bboxes :dict) -> dict:
144151
x_head = [x[0]-1]+x+[x[-1]+1]
145152
boxes = [boxes[0]]+boxes+[boxes[-1]]
146153

147-
fx0 = interp1d(x_head, [item[0] for item in boxes], kind = 'quadratic')
148-
fy0 = interp1d(x_head, [item[1] for item in boxes], kind = 'quadratic')
149-
fw = interp1d(x_head, [item[2] for item in boxes], kind = 'quadratic')
150-
fh = interp1d(x_head, [item[3] for item in boxes], kind = 'quadratic')
154+
fx0 = interp1d(x_head, [item[0] for item in boxes], kind = interpolation)
155+
fy0 = interp1d(x_head, [item[1] for item in boxes], kind = interpolation)
156+
fw = interp1d(x_head, [item[2] for item in boxes], kind = interpolation)
157+
fh = interp1d(x_head, [item[3] for item in boxes], kind = interpolation)
151158

152159
for i in range(min(x), max(x)+1):
153160
interpolated_bboxes[tracker_type][tracker_number].append((float(fx0(i)), float(fy0(i)), float(fw(i)), float(fh(i))))

funscript_editor/algorithms/signal.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,11 @@ def categorize_points(self, signal: list, points: list) -> dict:
484484

485485
grouped_points = {'min': [], 'max': []}
486486
for idx in points:
487-
if smothed_signal[idx] > avg[idx]:
488-
grouped_points['max'].append(idx)
489-
else:
490-
grouped_points['min'].append(idx)
487+
if -1 < idx < min((len(smothed_signal), len(avg))):
488+
if smothed_signal[idx] > avg[idx]:
489+
grouped_points['max'].append(idx)
490+
else:
491+
grouped_points['min'].append(idx)
491492

492493
return grouped_points
493494

funscript_editor/algorithms/videotracker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ def run(self) -> None:
241241
status = StaticVideoTracker.Status.FEATURE_OUTSIDE
242242
else:
243243
bbox = self.last_valid_tracking_box
244+
elif self.supervised_tracking_area is not None and not self.supervised_tracking_is_exit_condition:
245+
# TODO: When we insert the tracking area again make sure the point is below/above the last valid box
246+
pass
244247

245248

246249
self.queue_out.put((status, bbox))

funscript_editor/data/funscript.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ def add_action(self, position: int, time: int, insert_raw: bool = False):
216216
Returns:
217217
Funscript: current funscript instance
218218
"""
219-
print('raw is', insert_raw)
220219
self.changed = True
221220
if not insert_raw:
222221
self.delete_action(time)

0 commit comments

Comments
 (0)