Capturing video using raspberry pi with 64 bit OS

63 views Asked by At

I tried capturing video using Raspberry Pi 4 Model B 8GB RAM and OS of 64 bit. But unable to capture a video due to c2 error. Along with that I'm having no camera in interface option so I updated then libcamera interface=1 is shown. What should I do to capture a video?

import cv2

cam = cv2.VideoCapture(0)

face_cascade = cv2.CascadeClassifier("./opencv-4.x/data/haarcascades/haarcascade frontalface default.xml")

def detect_face(img):
    coord = face_cascade.detectMultiScale(img)  
    for (x,y,w,h) in coord:
        cv2.rectangle(img, (x,y), (x+w,y+h), (255, 255, 255),5)
    return img

while True:
    (ret, image) = cam.read()
    image detect_face(image)
    cv2.imshow('Preview', image)

    if cv2.waitKey(1) & 0xFF == ord('q'):
       break
1

There are 1 answers

0
toyota Supra On

Typo error missing underscore and equal.

Edit: Using Bullseye and Bookworm.

Change this:

"./opencv-4.x/data/haarcascades/haarcascade frontalface default.xml"

to:

"./opencv-4.x/data/haarcascades/haarcascade_frontalface_default.xml"

Change this:

image detect_face(image)

to:

image = detect_face(image)