Skip to content

Commit b9a5e39

Browse files
author
arch
committed
add is_vr_video check
1 parent 8bd6109 commit b9a5e39

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def scale_score(self, status: str, metric : str = 'y') -> None:
371371
cap.release()
372372

373373
if success_min and success_max:
374-
if 'vr' in self.params.projection.split('_'):
374+
if self.is_vr_video():
375375
if 'sbs' in self.params.projection.split('_'):
376376
imgMin = imgMin[:, :int(imgMin.shape[1]/2)]
377377
imgMax = imgMax[:, :int(imgMax.shape[1]/2)]
@@ -630,7 +630,7 @@ def tracking(self) -> str:
630630
"""
631631
first_frame = FFmpegStream.get_frame(self.params.video_path, self.params.start_frame)
632632

633-
if 'vr' in self.params.projection.split('_'):
633+
if self.is_vr_video():
634634
projection_config = self.get_vr_projection_config(first_frame)
635635
else:
636636
projection_config = self.get_flat_projection_config(first_frame)
@@ -799,8 +799,8 @@ def apply_shift(self, frame_number: int, metric: str, position: str) -> int:
799799
Returns:
800800
int: real frame position
801801
"""
802-
shift_max = self.params.shift_top_points if metric == 'y' else self.params.shift_max_points
803-
shift_min = self.params.shift_bottom_points if metric == 'y' else self.params.shift_min_points
802+
shift_max = self.params.shift_top_points if metric == 'y' and self.is_vr_video() else self.params.shift_max_points
803+
shift_min = self.params.shift_bottom_points if metric == 'y' and self.is_vr_video() else self.params.shift_min_points
804804

805805
if position in ['max'] :
806806
if frame_number >= -1*shift_max \
@@ -825,8 +825,8 @@ def get_score_with_offset(self, idx_dict: dict, metric: str) -> list:
825825
Returns:
826826
list: score with offset
827827
"""
828-
offset_max = self.params.top_points_offset if metric == 'y' else self.params.max_points_offset
829-
offset_min = self.params.bottom_points_offset if metric == 'y' else self.params.min_points_offset
828+
offset_max = self.params.top_points_offset if metric == 'y' and self.is_vr_video() else self.params.max_points_offset
829+
offset_min = self.params.bottom_points_offset if metric == 'y' and self.is_vr_video() else self.params.min_points_offset
830830

831831
score = copy.deepcopy(self.score[metric])
832832
score_min, score_max = min(score), max(score)
@@ -877,6 +877,15 @@ def determine_change_points(self, metric: str) -> dict:
877877
return sp.get_local_max_and_min_idx(self.score[metric], round(self.video_info.fps))
878878

879879

880+
def is_vr_video(self):
881+
""" Check if current video is set to VR
882+
883+
Returns:
884+
bool: true if VR is selected else false
885+
"""
886+
return 'vr' in self.params.projection.lower().split('_')
887+
888+
880889
def create_funscript(self, idx_dict: dict) -> None:
881890
""" Generate the Funscript
882891
@@ -895,8 +904,8 @@ def create_funscript(self, idx_dict: dict) -> None:
895904
else:
896905
output_score = self.get_score_with_offset(idx_dict, self.params.metric)
897906

898-
threshold_min = self.params.bottom_threshold if self.params.metric == 'y' else self.params.min_threshold
899-
threshold_max = self.params.top_threshold if self.params.metric == 'y' else self.params.max_threshold
907+
threshold_min = self.params.bottom_threshold if self.params.metric == 'y' and self.is_vr_video() else self.params.min_threshold
908+
threshold_max = self.params.top_threshold if self.params.metric == 'y' and self.is_vr_video() else self.params.max_threshold
900909

901910
for idx in idx_dict['min']:
902911
self.funscript.add_action(

0 commit comments

Comments
 (0)