Git Product home page Git Product logo

Comments (7)

ageitgey avatar ageitgey commented on May 3, 2024

This probably means OpenCV wasn't able to grab an image from your webcam. Can you try rebooting your computer and running it again?

from face_recognition.

parinfuture avatar parinfuture commented on May 3, 2024

Hi,
Rebooted my Raspberry Pi. I am still get the same error.

from face_recognition.

ageitgey avatar ageitgey commented on May 3, 2024

Oh, this is a raspberry pi. You put macOS in the issue description.

The RPi camera doesn't work with OpenCV like that. There's a separate code example for raspberry pis that uses the picamera module.

from face_recognition.

parinfuture avatar parinfuture commented on May 3, 2024

Is there any separate code module that can do live video processing on Raspberry Pi similar to this? https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py

from face_recognition.

ageitgey avatar ageitgey commented on May 3, 2024

The examples do almost the same thing. The only difference is the opencv example shows the video in a window while it processes it.

If you want to use the OpenCV example on an RPi, you could modify the OpenCV example to replace the part that captures the image:

# Get a reference to webcam #0 (the default one)
video_capture = cv2.VideoCapture(0)

# .. etc ..

while True:
    # Grab a single frame of video
    ret, frame = video_capture.read()

    # Resize frame of video to 1/4 size for faster face recognition processing
    small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)

with the equivalent code using picamera:

camera = picamera.PiCamera()
camera.resolution = (320, 240)
small_frame = np.empty((240, 320, 3), dtype=np.uint8)

# ... etc ...

while True:
    print("Capturing image.")
    # Grab a single frame of video from the RPi camera as a numpy array
    camera.capture(small_frame, format="bgr")
    camera.close()

And something like that should work.

from face_recognition.

parinfuture avatar parinfuture commented on May 3, 2024

@ageitgey Thanks for your help. Will definitely try this out.

from face_recognition.

ageitgey avatar ageitgey commented on May 3, 2024

Cool! 👍

from face_recognition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.