

Conversely, smaller values of accumWeight give more weight to the background model than the current frame, allowing you to detect larger changes in the foreground. Using a high value of accumWeight is useful if you except lots of motion in a short amount of time. A larger accumWeight will result in the background model having less “memory” and quickly “forgetting” what previous frames looked like.
#RASPBERRY PI ONVIF DRIVER#
We’ll then write a Python driver script that instantiates our two video streams and performs motion detection in both of them.Īs we’ll see, by using the threaded video stream capture classes (where one thread per camera is dedicated to perform I/O operations, allowing the main program thread to continue unblocked), we can easily get our motion detectors for multiple cameras to run in real-time on the Raspberry Pi 2. In the remainder of this blog post, we’ll define a simple motion detection class that can detect if a person/object is moving in the field of view of a given camera. Ignore the electrical tape and cardboard on the USB camera - this was from a previous experiment which should (hopefully) be published on the PyImageSearch blog soon.įinally, you can see an example of both video feeds displayed to my Raspberry Pi in the image below: Figure 3: An example screenshot of monitoring both video feeds from the multiple camera Raspberry Pi setup. The Raspberry Pi camera module is pointing towards my apartment door to monitor anyone that is entering and leaving, while the USB webcam is pointed towards the kitchen, observing any activity that may be going on: Figure 2: The Raspberry Pi camera module and USB camera are both hooked up to my Raspberry Pi, but are monitoring different areas of the room. Here we can see my Raspberry Pi 2, along with the Raspberry Pi camera module (sitting on top of the Pi 2) and my Logitech C920 webcam. You can see an example of my setup below: Figure 1: My multiple camera Raspberry Pi setup. We can access this camera using either the cv2.VideoCapture function built-in to OpenCV or the VideoStream class from this lesson. A Logitech C920 webcam that is plug-and-play compatible with the Raspberry Pi.

We can interface with the camera using the picamera Python package or (preferably) the threaded VideoStream class defined in a previous blog post.

That said, in order to build my own multi-camera Raspberry Pi setup, I ended up using: So in order to attach multiple cameras to your Pi, you’ll need to leverage at least one (if not more) USB cameras. The Raspberry Pi board has only one camera port, so you will not be able to use multiple Raspberry Pi camera boards (unless you want to perform some extensive hacks to your Pi).
#RASPBERRY PI ONVIF CODE#
Looking for the source code to this post? Jump Right To The Downloads Section Multiple cameras with the Raspberry Pi and OpenCV
