parent
df72a5431b
commit
97a76c5e5b
|
@ -1404,14 +1404,15 @@ def create_webcam_preview(camera_index: int):
|
||||||
|
|
||||||
# FPS tracking variables
|
# FPS tracking variables
|
||||||
prev_time = time.time()
|
prev_time = time.time()
|
||||||
fps_update_interval = 1.0
|
fps_update_interval = 1.0 # Increased to 1 second for stability
|
||||||
frame_count = 0
|
frame_count = 0
|
||||||
fps = 0
|
fps = 0
|
||||||
fps_display = "FPS: --"
|
fps_display = "FPS: --" # Initialize fps display text
|
||||||
|
|
||||||
# Remove cached show_fps value - we'll check it in real-time instead
|
# Cache frequently accessed values
|
||||||
live_mirror = modules.globals.live_mirror
|
live_mirror = modules.globals.live_mirror
|
||||||
live_resizable = modules.globals.live_resizable
|
live_resizable = modules.globals.live_resizable
|
||||||
|
show_fps = modules.globals.show_fps
|
||||||
map_faces = modules.globals.map_faces
|
map_faces = modules.globals.map_faces
|
||||||
|
|
||||||
while camera.isOpened() and PREVIEW.state() != "withdrawn":
|
while camera.isOpened() and PREVIEW.state() != "withdrawn":
|
||||||
|
@ -1437,20 +1438,20 @@ def create_webcam_preview(camera_index: int):
|
||||||
for frame_processor in frame_processors:
|
for frame_processor in frame_processors:
|
||||||
temp_frame = frame_processor.process_frame_v2(temp_frame)
|
temp_frame = frame_processor.process_frame_v2(temp_frame)
|
||||||
|
|
||||||
# FPS calculation (always calculate it)
|
# FPS calculation and display
|
||||||
frame_count += 1
|
frame_count += 1
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
if current_time - prev_time >= fps_update_interval:
|
if current_time - prev_time >= fps_update_interval:
|
||||||
fps = frame_count / (current_time - prev_time)
|
fps = frame_count / (current_time - prev_time)
|
||||||
fps_display = f"FPS: {fps:.1f}"
|
fps_display = f"FPS: {fps:.1f}" # Update display text
|
||||||
frame_count = 0
|
frame_count = 0
|
||||||
prev_time = current_time
|
prev_time = current_time
|
||||||
|
|
||||||
# Check show_fps state in real-time
|
# Always show the last calculated FPS value
|
||||||
if modules.globals.show_fps:
|
if show_fps:
|
||||||
cv2.putText(
|
cv2.putText(
|
||||||
temp_frame,
|
temp_frame,
|
||||||
fps_display,
|
fps_display, # Use stored fps display text
|
||||||
(10, 30),
|
(10, 30),
|
||||||
cv2.FONT_HERSHEY_SIMPLEX,
|
cv2.FONT_HERSHEY_SIMPLEX,
|
||||||
1,
|
1,
|
||||||
|
|
Loading…
Reference in New Issue