From e477014549fa90936157e601b57ca52ddf33b773 Mon Sep 17 00:00:00 2001 From: shawn-sheep Date: Mon, 3 Jul 2023 23:19:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=91=84=E5=83=8F?= =?UTF-8?q?=E5=A4=B4=E7=9A=84bug=20=09modified:=20=20=20helloworld.py=20?= =?UTF-8?q?=09modified:=20=20=20sub=5Fwindows/sub=5Fwindow=5F8.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helloworld.py | 7 ++++--- sub_windows/sub_window_8.py | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/helloworld.py b/helloworld.py index 3337a83..d1239a5 100644 --- a/helloworld.py +++ b/helloworld.py @@ -1,5 +1,4 @@ import cv2 - def detect_cameras(max_cameras=10): cameras = [] for i in range(max_cameras): @@ -11,5 +10,7 @@ def detect_cameras(max_cameras=10): cap.release() return cameras -available_cameras = detect_cameras() -print(f'Found {len(available_cameras)} camera(s): {available_cameras}') +# available_cameras = detect_cameras() +# print(f'Found {len(available_cameras)} camera(s): {available_cameras}' + +print(cv2.__version__) \ No newline at end of file diff --git a/sub_windows/sub_window_8.py b/sub_windows/sub_window_8.py index 2379873..e2c113e 100644 --- a/sub_windows/sub_window_8.py +++ b/sub_windows/sub_window_8.py @@ -59,7 +59,9 @@ class FaceDetect(QThread): def run(self): face_cascade = cv2.CascadeClassifier('./static/cascade.xml') - capture = cv2.VideoCapture(0) + capture = cv2.VideoCapture(0, cv2.CAP_DSHOW) + codec = cv2.VideoWriter_fourcc("M", "J", "P", "G") + capture.set(cv2.CAP_PROP_FOURCC, codec) while self.working: ret, frame_color = capture.read() (height, width, channels) = frame_color.shape