22import cv2
33import time
44import psutil
5- from .draw import draw_text_multiline
5+ from .draw import draw_text_multiline , render_resolution
66
77
88def is_raspberry ():
@@ -24,7 +24,7 @@ def __init__(self, src=0, resolution=(1920, 1080), fps=30, dest=None):
2424 from libcamera import Transform
2525 self .picam2 = Picamera2 ()
2626 self .picam2 .configure (self .picam2 .create_video_configuration (
27- main = {"format" : 'BGR888 ' , "size" : resolution },
27+ main = {"format" : 'RGB888 ' , "size" : resolution },
2828 transform = Transform (hflip = True , vflip = True ),
2929 controls = {"FrameRate" : fps }))
3030 self .picam2 .start ()
@@ -94,12 +94,13 @@ def show(self, frame):
9494 draw_text_multiline (frame , [f"FPS: { round (1 / (t1 - self .t0 ), 1 )} " ,
9595 f"CPU: { psutil .cpu_percent ()} %" ,
9696 f"RAM: { round (psutil .virtual_memory ().used / (1024 ** 3 ), 2 )} GB" ], (10 , 40 ), background_color = (192 , 192 , 192 ))
97+ render_resolution (frame )
9798 self .t0 = t1
9899 if not self .win_name :
99100 self .win_name = 'Video'
100101 cv2 .namedWindow (self .win_name , cv2 .WINDOW_GUI_NORMAL )
101102 cv2 .imshow (self .win_name , cv2 .cvtColor (frame , cv2 .COLOR_RGB2BGR ))
102- ch = 0xFF & cv2 .waitKey (1 if self . picam2 else int (self .fps ))
103+ ch = 0xFF & cv2 .waitKey (int (self .fps ))
103104 if (ch == 27 or ch == ord ('q' )) or cv2 .getWindowProperty (self .win_name , cv2 .WND_PROP_VISIBLE ) < 1 :
104105 self .quit = True
105106
0 commit comments