Skip to content

Commit 672ba2c

Browse files
author
arch
committed
fix scaling for equirectangular
1 parent 4defd08 commit 672ba2c

File tree

2 files changed

+15
-260
lines changed

2 files changed

+15
-260
lines changed

funscript_editor/algorithms/equirectangular.py

Lines changed: 0 additions & 250 deletions
This file was deleted.

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class FunscriptGeneratorParameter:
4343
scaling_method :str = SETTINGS['scaling_method']
4444
top_threshold :float = float(HYPERPARAMETER['top_threshold'])
4545
bottom_threshold :float = float(HYPERPARAMETER['bottom_threshold'])
46+
equirectangular_height :int = 720
47+
equirectangular_width :int = 1240
48+
equirectangular_fov :int = 100
4649

4750

4851
class FunscriptGenerator(QtCore.QThread):
@@ -309,7 +312,6 @@ def scale_score(self, status: str, direction : str = 'y') -> None:
309312
cap = cv2.VideoCapture(self.params.video_path)
310313
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
311314
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
312-
scale = self.get_scaling(width, height)
313315

314316
if direction == 'x':
315317
min_frame = np.argmin(np.array(self.score_x)) + self.params.start_frame
@@ -326,8 +328,14 @@ def scale_score(self, status: str, direction : str = 'y') -> None:
326328
cap.release()
327329

328330
if successMin and successMax:
329-
imgMin = cv2.resize(imgMin, None, fx=scale, fy=scale)
330-
imgMax = cv2.resize(imgMax, None, fx=scale, fy=scale)
331+
if self.params.use_equirectangular:
332+
dim = (int(self.params.equirectangular_width*self.params.equirectangular_scaling), int(self.params.equirectangular_height*self.params.equirectangular_scaling))
333+
imgMin = cv2.resize(imgMin, dim)
334+
imgMax = cv2.resize(imgMax, dim)
335+
else:
336+
scale = self.get_scaling(width, height)
337+
imgMin = cv2.resize(imgMin, None, fx=scale, fy=scale)
338+
imgMax = cv2.resize(imgMax, None, fx=scale, fy=scale)
331339

332340
# Assume we have VR 3D Side by Side
333341
imgMin = imgMin[:, :int(imgMin.shape[1]/2)]
@@ -417,11 +425,11 @@ def get_perspective_roi(self, image :np.ndarray) -> None:
417425
image (np.ndarray): opencv vr 180 or 360 image
418426
"""
419427
perspective = {
420-
'FOV': 100,
428+
'FOV': self.params.equirectangular_fov,
421429
'THETA': -90,
422430
'PHI': -45,
423-
'height': int(720*self.params.equirectangular_scaling),
424-
'width': int(1240*self.params.equirectangular_scaling)
431+
'height': int(self.params.equirectangular_height*self.params.equirectangular_scaling),
432+
'width': int(self.params.equirectangular_width*self.params.equirectangular_scaling)
425433
}
426434

427435
selected = False
@@ -522,11 +530,8 @@ def tracking(self) -> str:
522530
Returns:
523531
str: a process status message e.g. 'end of video reached'
524532
"""
525-
first_frame = self.get_first_frame()
526-
if first_frame is None:
527-
return 'Video file is corrupt'
528-
529533
if self.params.use_equirectangular:
534+
first_frame = self.get_first_frame()
530535
self.get_perspective_roi(first_frame)
531536

532537
video = EquirectangularVideoStream(

0 commit comments

Comments
 (0)