Я запускаю программу распознавания лиц с OpenCv на Raspberry Pi3. Это мой python код:
import cv2
# Load the cascade
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# To capture video from webcam
cap = cv2.VideoCapture(0)
# To use a video file as input
# cap = cv2.VideoCapture('filename.mp4')
while True:
# Read the frame
_, img = cap.read()
# Convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Detect the faces
faces = face_cascade.detectMultiScale(gray, 1.1, 4)
# Draw the rectangle around each face
for (x, y, w, h) in faces:
cv2.rectangle(img, (x, y), (x+w, y+h), (250, 0, 0), 0)
# Display
cv2.imshow('Webcam', img)
# Stop if escape key is pressed
k = cv2.waitKey(0) & 0xff
if k==27:
break
# Release the VideoCapture object
cap.release()
Код уже работает. Моя единственная проблема заключается в том, что окно, в котором вы можете видеть, что камера снимает, не открывается в полноэкранном режиме.
Я хотел бы иметь его в полноэкранном режиме (и, возможно, также на 20 FPS (FPS, вероятно, на 30 справа) сейчас)).
Большое спасибо.