From 8f8a0528be7ff33ed2e86ad08b1f707271582812 Mon Sep 17 00:00:00 2001 From: Cyrus Ngan Date: Thu, 4 May 2023 13:48:48 +0800 Subject: [PATCH] Update facerec_from_webcam_faster.py Use cv2.cvtColor to convert BGR to RGB --- examples/facerec_from_webcam_faster.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/facerec_from_webcam_faster.py b/examples/facerec_from_webcam_faster.py index e4a7bbd47..a22728072 100644 --- a/examples/facerec_from_webcam_faster.py +++ b/examples/facerec_from_webcam_faster.py @@ -48,7 +48,8 @@ small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25) # Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses) - rgb_small_frame = small_frame[:, :, ::-1] + code = cv2.COLOR_BGR2RGB + rgb_small_frame = cv2.cvtColor(small_frame, code) # Find all the faces and face encodings in the current frame of video face_locations = face_recognition.face_locations(rgb_small_frame)