Skip to content

Commit e098c6e

Browse files
author
arch
committed
visualize points
1 parent 923be17 commit e098c6e

File tree

2 files changed

+8
-34
lines changed

2 files changed

+8
-34
lines changed

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -267,35 +267,17 @@ def scale_score(self, status: str, metric : str = 'y') -> None:
267267
imgMax = FFmpegStream.get_frame(self.params.video_path, max_frame)
268268

269269
if success_min and success_max:
270-
if self.is_vr_video():
271-
if 'sbs' in self.params.projection.split('_'):
272-
imgMin = imgMin[:, :int(imgMin.shape[1]/2)]
273-
imgMax = imgMax[:, :int(imgMax.shape[1]/2)]
274-
elif 'ou' in self.params.projection.split('_'):
275-
imgMin = imgMin[:int(imgMin.shape[0]/2), :]
276-
imgMax = imgMax[:int(imgMax.shape[0]/2), :]
277-
else:
278-
self.logger.warning("Unknown VR Projection Type: %s", self.params.projection)
279-
280-
if PROJECTION[self.params.projection]['parameter']['width'] > 0:
281-
scale = PROJECTION[self.params.projection]['parameter']['width'] / float(1.75*imgMax.shape[1])
282-
else:
283-
scale = PROJECTION[self.params.projection]['parameter']['height'] / float(1.75*imgMax.shape[0])
284-
285-
imgMin = cv2.resize(imgMin, None, fx=scale, fy=scale)
286-
imgMax = cv2.resize(imgMax, None, fx=scale, fy=scale)
270+
imgMin = FFmpegStream.get_projection(imgMin, self.projection_config)
271+
imgMax = FFmpegStream.get_projection(imgMax, self.projection_config)
287272

288273
min_tracking_points = self.get_tracking_points_by_frame_number(min_frame - self.params.start_frame)
289274
max_tracking_points = self.get_tracking_points_by_frame_number(max_frame - self.params.start_frame)
290275

291-
# TODO: draw points to image
292-
# NOTE: Code below does not work because image do not use the same projection
293-
294-
# for points in min_tracking_points:
295-
# imgMin = OpenCV_GUI.draw_point_to_image(imgMin, points)
276+
for points in min_tracking_points:
277+
imgMin = OpenCV_GUI.draw_point_to_image(imgMin, points)
296278

297-
# for points in max_tracking_points:
298-
# imgMax = OpenCV_GUI.draw_point_to_image(imgMax, points)
279+
for points in max_tracking_points:
280+
imgMax = OpenCV_GUI.draw_point_to_image(imgMax, points)
299281

300282
# print('min_tracking_points', min_tracking_points, 'max_tracking_points', max_tracking_points)
301283

@@ -512,11 +494,11 @@ def tracking(self) -> str:
512494
"""
513495
first_frame = FFmpegStream.get_frame(self.params.video_path, self.params.start_frame)
514496

515-
projection_config = self.ui.get_video_projection_config(first_frame, self.params.projection)
497+
self.projection_config = self.ui.get_video_projection_config(first_frame, self.params.projection)
516498

517499
video = FFmpegStream(
518500
video_path = self.params.video_path,
519-
config = projection_config,
501+
config = self.projection_config,
520502
skip_frames = self.params.skip_frames,
521503
start_frame = self.params.start_frame
522504
)

funscript_editor/config/projection.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ vr_he_180_ou:
105105
decrease: "+"
106106

107107

108-
flat:
109-
name: '2D Video'
110-
video_filter: "scale=${width}:${height}"
111-
parameter:
112-
height: 720
113-
width: -1
114-
115-
116108
flat_with_parameters:
117109
name: '2D Video with Filters'
118110
video_filter: "pad='max(ih,iw):max(ih,iw):max(ih,iw)/2:max(ih,iw)/2',scale=${width}:${height},rotate='(PI/180)*${rotation}',crop='iw*1/max(1, ${zoom}/5):ih*1/max(1, ${zoom}/5):2*${x}:2*${y}',scale=${width}:${height}"

0 commit comments

Comments
 (0)