Skip to content

Commit 8e0dceb

Browse files
author
arch
committed
improve x-Motion tracking
1 parent 3b9672f commit 8e0dceb

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ def calculate_score(self) -> None:
296296
We use x0,y0 from the predicted tracking boxes to create a diff score
297297
"""
298298
if self.params.track_men:
299-
self.score['x'] = [m[0] - w[0] for w, m in zip(self.bboxes['Woman'], self.bboxes['Men'])]
299+
self.score['x'] = [w[0] - m[0] for w, m in zip(self.bboxes['Woman'], self.bboxes['Men'])]
300300
self.score['y'] = [m[1] - w[1] for w, m in zip(self.bboxes['Woman'], self.bboxes['Men'])]
301-
self.score['d'] = [np.sqrt(np.sum((np.array(m[:2]) - np.array(w[:2])) ** 2, axis=0)) for w, m in zip(bboxes['Woman'], bboxes['Men'])]
301+
self.score['d'] = [np.sqrt(np.sum((np.array(m[:2]) - np.array(w[:2])) ** 2, axis=0)) for w, m in zip(self.bboxes['Woman'], self.bboxes['Men'])]
302302
else:
303-
self.score['x'] = [max([x[0] for x in self.bboxes['Woman']]) - w[0] for w in self.bboxes['Woman']]
303+
self.score['x'] = [w[0] - min([x[0] for x in self.bboxes['Woman']]) for w in self.bboxes['Woman']]
304304
self.score['y'] = [max([x[1] for x in self.bboxes['Woman']]) - w[1] for w in self.bboxes['Woman']]
305305
# TODO: how to calc d?
306306

funscript_editor/config/hyperparameter.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,26 @@ bottom_threshold: 2.5
5151
# x-Movement #
5252
##############
5353

54-
# Shift predicted right points by given frame number. Positive values delay the position
55-
# and negative values result in an earlier position.
56-
shift_right_points: 0
57-
5854
# Shift predicted left points by given frame number. Positive values delay the position
5955
# and negative values result in an earlier position.
6056
shift_left_points: 0
6157

58+
# Shift predicted right points by given frame number. Positive values delay the position
59+
# and negative values result in an earlier position.
60+
shift_right_points: 0
61+
6262
# An fix offset to the left points (positive values move the point right and negative values
6363
# move the point left). The offset respect the user defined upper and lower limit.
64-
left_points_offset: 0.0
64+
left_points_offset: -10.0
6565

6666
# An fix offset to the right points (positive values move the point right and negative values
6767
# move the point left). The offset respect the user defined upper and lower limit.
68-
right_points_offset: 0.0
69-
70-
# Define the right threshold. All right points greater than (max - threshold) will be set to
71-
# the specified max value. Set 0.0 to disable this function.
72-
right_threshold: 0.0
68+
right_points_offset: 10.0
7369

7470
# Define the left threshold. All left points lower than (min + threshold) will be set to
7571
# the specified min value. Set 0.0 to disable this function.
76-
left_threshold: 0.0
72+
left_threshold: 2.5
73+
74+
# Define the right threshold. All right points greater than (max - threshold) will be set to
75+
# the specified max value. Set 0.0 to disable this function.
76+
right_threshold: 2.5

funscript_editor/config/settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ preview_scaling: 0.6
2626
# Available Options:
2727
# - 'flat': 2D Videos
2828
# - 'vr_he_sbs': 3D VR Side-By-Side Video
29-
projection: 'vr_he_sbs'
29+
projection: 'flat'

funscript_editor/ui/funscript_editor_window.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,12 @@ def __generate_funscript(self):
291291
if self.funscript is None: return
292292
if self.video_player is None: return
293293
if self.video_player.get_video_file is None: return
294-
start_frame = self.video_player.get_current_frame \
295-
if self.funscript.get_last_action_time() < self.video_player.get_current_timestamp_in_millis \
296-
else self.video_player.millisec_to_frame(self.funscript.get_last_action_time())
294+
start_frame = self.video_player.get_current_frame
295+
next_action = self.funscript.get_next_action(self.video_player.get_current_timestamp_in_millis+100)
296+
if next_action['at'] > self.video_player.get_current_timestamp_in_millis+100:
297+
end_frame = self.video_player.millisec_to_frame(next_action['at'])
298+
else:
299+
end_frame = -1
297300

298301
reply = QtWidgets.QMessageBox.question(None, 'Track Men', 'Do you want to track the Men? ',
299302
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No)
@@ -304,6 +307,7 @@ def __generate_funscript(self):
304307
FunscriptGeneratorParameter(
305308
video_path = self.video_player.get_video_file,
306309
start_frame = start_frame,
310+
end_frame = end_frame,
307311
track_men = trackMen
308312
),
309313
self.funscript)

0 commit comments

Comments
 (0)