更新Demo

main
PEAandDA 2024-07-22 20:12:25 +08:00
parent 7121d24a90
commit b6f672389e
1 changed files with 7 additions and 8 deletions

View File

@ -23,20 +23,19 @@ class CameraThread(QThread):
ret, frame = self.cap.read() ret, frame = self.cap.read()
if ret: if ret:
rgb_image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) rgb_image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
img, bboxs = self.face_detector.find_faces(rgb_image) original_img, img, bboxs = self.face_detector.find_faces(rgb_image)
face_img = None face_img = None
max_roi = 0
for bbox in bboxs: for bbox in bboxs:
try: try:
x, y, w, h = bbox[1] x, y, w, h, confidence = bbox
if w * h > max_roi: face_img = img[y:y + h, x:x + w]
max_roi = w * h except Exception as e:
face_img = img[y:y + h, x:x + w] print(e)
except:
pass pass
self.new_frame.emit(img) self.new_frame.emit(original_img)
if face_img is not None: if face_img is not None:
self.fps_signal.emit(self.fps) self.fps_signal.emit(self.fps)
self.storage_frame.emit(cv2.resize(face_img, (224, 224))) self.storage_frame.emit(cv2.resize(face_img, (224, 224)))