Skip to content

Commit bffc26c

Browse files
committed
fixed fast updating of video frame rate
1 parent d1eea32 commit bffc26c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

camera-app.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ def update_video_frame():
103103
photo = ImageTk.PhotoImage(image=img)
104104
video_label.config(image=photo)
105105
video_label.image = photo
106-
video_player.after(10, update_video_frame)
106+
107+
# Get the actual frame rate of the video
108+
frame_rate = video_cap.get(cv2.CAP_PROP_FPS)
109+
110+
# Calculate the delay based on the original frame rate
111+
delay = int(1000 / frame_rate)
112+
113+
video_player.after(delay, update_video_frame) # Delay based on frame rate
107114
else:
108115
video_player.destroy()
109116

@@ -215,7 +222,7 @@ def show_image_in_gallery(img_path, img_name):
215222
# Create buttons
216223
capture_button = tk.Button(root, text="Capture", command=capture_image)
217224
record_button = tk.Button(root, text="Record", command=start_recording)
218-
stop_button = tk.Button(root, text="Stop", command=stop_recording)
225+
stop_button = tk.Button(root, text="Stop Recording", command=stop_recording)
219226
gallery_button = tk.Button(root, text="Gallery", command=open_gallery)
220227
quit_button = tk.Button(root, text="Quit", command=root.quit)
221228

0 commit comments

Comments
 (0)