face Detect day2
face Detect day2
#!/usr/bin/python3
import cv2
from picamera2 import Picamera2
# Initialize Picamera2
picam2 = Picamera2()
picam2.configure(picam2.create_preview_configuration(main={"format": 'XRGB8888', "size":
(640, 480)}))
picam2.start()
while True:
# Capture a frame from the camera
frame = picam2.capture_array()
# Detect faces
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5,
minSize=(30, 30))
# Clean up
cv2.destroyAllWindows()
picam2.stop()
import time
fps_start = time.time()
frame_count = 0
while True:
frame = picam2.capture_array()
frame_count += 1
###############################################################
If pip install numpy picamera2 is not working on Raspberry Pi 5, try the following
solutions:
📌 Summary of Fixes
✔ Update the system (sudo apt update && sudo apt full-upgrade -y)
✔ Install python3-picamera2 and python3-numpy using apt
✔ Test the installation with python3 -c "import picamera2"
✔ Use a virtual environment if needed
Try these steps and let me know if you need more help! 🚀