Skip to content

Commit fabee9d

Browse files
author
arch
committed
add user reaction time as hyperparameter to config
1 parent 4d24209 commit fabee9d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ def tracking(self) -> str:
872872

873873
if self.was_key_pressed('q') or cv2.waitKey(1) == ord('q'):
874874
status = 'Tracking stopped by user'
875-
delete_last_predictions = int((self.get_average_tracking_fps()+1)*2.0)
875+
delete_last_predictions = max((1, int((self.get_average_tracking_fps()+1)*HYPERPARAMETER['user_reaction_time_in_milliseconds']/1000.0)))
876876
break
877877

878878
for tracker_number in range(self.params.number_of_trackers):

funscript_editor/algorithms/signalprocessing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def moving_average(x :list, w: int) -> list:
6060
list: moving average for signal x
6161
"""
6262
w = round(w)
63+
if len(x) == 0: return []
64+
if len(x) <= w+1: return[np.mean(x) for _ in range(len(x))]
6365
avg = np.convolve(x, np.ones(int(w*2)), 'valid') / int(w*2)
6466
# TODO use extrapolation function
6567
return [avg[0] for _ in range(int(w))]\
@@ -78,6 +80,8 @@ def moving_standard_deviation(x: list, w: int) -> list:
7880
list: moving standard deviation
7981
"""
8082
w = round(w)
83+
if len(x) == 0: return []
84+
if len(x)-w <= w: return[np.std(x) for _ in range(len(x))]
8185
std = [np.std(x[ii-w:ii+w+1]) for ii in range(w,len(x)-w)]
8286
# TODO use extrapolation function
8387
return [std[0] for _ in range(w)]\

funscript_editor/config/hyperparameter.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ changepoint_detection_threshold: 1.2
2929
# threshold value in milliseconds to merge additional change points
3030
additional_changepoints_merge_threshold_in_ms: 100
3131

32+
# reaction time of the user to stop the tracking when scene changed or tracking box shifts
33+
user_reaction_time_in_milliseconds: 1500
34+
3235

3336
##################
3437
# Scene Detector #

0 commit comments

Comments
 (0)