Skip to content

Commit a3a7857

Browse files
author
arch
committed
make preview fps more smooth
1 parent dbfebe8 commit a3a7857

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ def draw_fps(self, img: np.ndarray) -> np.ndarray:
159159
Returns:
160160
np.ndarray: opencv image with FPS Text
161161
"""
162+
SMOOT_FACTOR = 100
162163
annotated_img = img.copy()
163-
fps = (self.params.skip_frames+1)*cv2.getTickFrequency()/(cv2.getTickCount()-self.timer)
164-
self.tracking_fps.append(fps)
164+
self.tracking_fps.append((self.params.skip_frames+1)*cv2.getTickFrequency()/(cv2.getTickCount()-self.timer))
165+
fps = np.mean((self.tracking_fps[-SMOOT_FACTOR:] if len(self.tracking_fps) < SMOOT_FACTOR else self.tracking_fps))
165166
cv2.putText(annotated_img, str(int(fps)) + ' fps', (self.x_text_start, 50),
166167
cv2.FONT_HERSHEY_SIMPLEX, self.font_size, (0,0,255), 2)
167168
self.timer = cv2.getTickCount()

0 commit comments

Comments
 (0)