Skip to content

Commit 01b8054

Browse files
author
arch
committed
add zoom factor by config
1 parent bcab9b1 commit 01b8054

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

docs/app/docs/user-guide/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Config Files:
2828
#### `settings.yaml`
2929

3030
- `use_zoom` (bool): Enable or disable an additional step to zoom in the Video before selecting a tracking feature for the Woman or Men.
31+
- `zoom_factor:` (float): Set the desired zoom value which will be used when the zoom function is activated.
3132
- `use_equirectangular` (bool): Convert video in normal perspective view before apply tracking. This should improve the tracking at the border of videos, because there is the distortion very high.
3233
- `equirectangular_scaling` (float): scaling parameter for the equirectangular preview window. `1.0` is `1240x720`, `1.5` would be `1860x1080`, ... (Do not use to high scaling values, the perspective calculation need a lot of computer resources!)
3334

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@
2828
class FunscriptGeneratorParameter:
2929
""" Funscript Generator Parameter Dataclass with default values """
3030
video_path: str # no default value
31-
start_frame: int = 0 # default is video start
32-
skip_frames: int = HYPERPARAMETER['skip_frames']
33-
max_playback_fps: int = SETTINGS['max_playback_fps']
31+
start_frame: int = 0 # default is video start (input: set current video position)
32+
track_men: bool = True # set by userinput at start (message box)
33+
skip_frames: int = max((0, int(HYPERPARAMETER['skip_frames'])))
34+
max_playback_fps: int = max((0, int(SETTINGS['max_playback_fps'])))
3435
direction: str = SETTINGS['tracking_direction']
3536
use_zoom: bool = SETTINGS['use_zoom']
36-
shift_bottom_points :int = HYPERPARAMETER['shift_bottom_points']
37-
shift_top_points :int = HYPERPARAMETER['shift_top_points']
37+
shift_bottom_points :int = int(HYPERPARAMETER['shift_bottom_points'])
38+
shift_top_points :int = int(HYPERPARAMETER['shift_top_points'])
3839
use_equirectangular :bool = SETTINGS['use_equirectangular']
39-
equirectangular_scaling :float = SETTINGS['equirectangular_scaling']
40-
track_men: bool = True
40+
equirectangular_scaling :float = max((0.2, float(SETTINGS['equirectangular_scaling'])))
41+
zoom_factor :float = max((1.0, float(SETTINGS['zoom_factor'])))
4142

4243

4344
class FunscriptGenerator(QtCore.QThread):
@@ -453,13 +454,13 @@ def get_bbox(self, image: np.ndarray, txt: str) -> tuple:
453454
while True:
454455
zoom_bbox = cv2.selectROI(self.window_name, self.drawText(image, "Zoom selected area"), False)
455456
if zoom_bbox is None or len(zoom_bbox) == 0: continue
456-
if zoom_bbox[2] < 100 or zoom_bbox[3] < 100:
457+
if zoom_bbox[2] < 75 or zoom_bbox[3] < 75:
457458
self.__logger.error("The selected zoom area is to small")
458459
continue
459460
break
460461

461462
image = image[zoom_bbox[1]:zoom_bbox[1]+zoom_bbox[3], zoom_bbox[0]:zoom_bbox[0]+zoom_bbox[2]]
462-
image = cv2.resize(image, None, fx=2, fy=2)
463+
image = cv2.resize(image, None, fx=self.params.zoom_factor, fy=self.params.zoom_factor)
463464

464465
while True:
465466
bbox = cv2.selectROI(self.window_name, self.drawText(image, txt), False)
@@ -468,8 +469,11 @@ def get_bbox(self, image: np.ndarray, txt: str) -> tuple:
468469
break
469470

470471
if self.params.use_zoom:
471-
# NOTE: we upscale the preview by 2
472-
bbox = (round(bbox[0]/2)+zoom_bbox[0], round(bbox[1]/2)+zoom_bbox[1], round(bbox[2]/2), round(bbox[3]/2))
472+
bbox = (round(bbox[0]/self.params.zoom_factor)+zoom_bbox[0],
473+
round(bbox[1]/self.params.zoom_factor)+zoom_bbox[1],
474+
round(bbox[2]/self.params.zoom_factor),
475+
round(bbox[3]/self.params.zoom_factor)
476+
)
473477

474478
return bbox
475479

@@ -489,9 +493,6 @@ def tracking(self) -> str:
489493
if first_frame is None:
490494
return 'Video file is corrupt'
491495

492-
if self.params.skip_frames < 0:
493-
self.params.skip_frames = 0
494-
495496
if self.params.use_equirectangular:
496497
self.get_perspective_roi(first_frame)
497498
first_frame = Equirectangular.get_perspective(

funscript_editor/config/settings.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# feature for the Woman or Men.
55
use_zoom: False
66

7+
# Set the desired zoom value which will be used when the zoom function is activated.
8+
zoom_factor: 4.0
9+
710
# Convert video in normal perspective view before apply tracking. This should improve the
811
# tracking at the border of videos, because there is the distortion very high.
912
use_equirectangular: False

0 commit comments

Comments
 (0)