|
2 | 2 |
|
3 | 3 | import cv2 |
4 | 4 | import json |
| 5 | +import copy |
5 | 6 | import time |
6 | 7 | import logging |
7 | 8 |
|
@@ -37,6 +38,8 @@ class FunscriptGeneratorParameter: |
37 | 38 | use_zoom: bool = SETTINGS['use_zoom'] |
38 | 39 | shift_bottom_points :int = int(HYPERPARAMETER['shift_bottom_points']) |
39 | 40 | shift_top_points :int = int(HYPERPARAMETER['shift_top_points']) |
| 41 | + top_points_offset :float = float(HYPERPARAMETER['top_points_offset']) |
| 42 | + bottom_points_offset :float = float(HYPERPARAMETER['bottom_points_offset']) |
40 | 43 | use_equirectangular :bool = SETTINGS['use_equirectangular'] |
41 | 44 | equirectangular_scaling :float = max((0.2, float(SETTINGS['equirectangular_scaling']))) |
42 | 45 | zoom_factor :float = max((1.0, float(SETTINGS['zoom_factor']))) |
@@ -710,6 +713,28 @@ def apply_shift(self, frame_number, position: str) -> int: |
710 | 713 |
|
711 | 714 | return self.params.start_frame + frame_number |
712 | 715 |
|
| 716 | + def get_score_with_offset(self, idx_dict) -> list: |
| 717 | + """ Apply the offsets form config file |
| 718 | +
|
| 719 | + Args: |
| 720 | + idx_dict (dict): the idx dictionary with {'min':[], 'max':[]} idx lists |
| 721 | +
|
| 722 | + Returns: |
| 723 | + list: score with offset |
| 724 | + """ |
| 725 | + if self.params.direction == 'x': |
| 726 | + return self.score_x |
| 727 | + |
| 728 | + score = copy.deepcopy(self.score_y) |
| 729 | + score_min, score_max = min(score), max(score) |
| 730 | + for idx in idx_dict['min']: |
| 731 | + score[idx] = max(( score_min, min((score_max, score[idx] + self.params.bottom_points_offset)) )) |
| 732 | + |
| 733 | + for idx in idx_dict['max']: |
| 734 | + score[idx] = max(( score_min, min((score_max, score[idx] + self.params.top_points_offset)) )) |
| 735 | + |
| 736 | + return score |
| 737 | + |
713 | 738 |
|
714 | 739 | def run(self) -> None: |
715 | 740 | """ The Funscript Generator Thread Function """ |
@@ -739,7 +764,7 @@ def run(self) -> None: |
739 | 764 | if self.params.direction != 'x': |
740 | 765 | self.plot_y_score('debug_002.png', idx_list) |
741 | 766 |
|
742 | | - output_score = self.score_y if self.params.direction != 'x' else self.score_x |
| 767 | + output_score = self.get_score_with_offset(idx_dict) |
743 | 768 | for idx in idx_dict['min']: |
744 | 769 | self.funscript.add_action( |
745 | 770 | min(output_score) \ |
|
0 commit comments