

# determine the OpenCV version, followed by storing the Let’s get started by opening a new file, naming it basicmotiondetector.py, and adding in the following code: # import the necessary packagesĭef _init_(self, accumWeight=0.5, deltaThresh=5, minArea=5000): In fact, we have already (partially) reviewed this motion detection method in our previous lesson, home surveillance and motion detection with the Raspberry Pi, Python, OpenCV, and Dropbox - we are now formalizing this implementation into a reusable class rather than just inline code. In this section, we’ll build a simple Python class that can be used to detect motion in a field of view of a given camera.įor efficiency, this class will assume there is only one object moving in the camera view at a time - in future blog posts, we’ll look at more advanced motion detection and background subtraction methods to track multiple objects. Let’s go ahead and get started by defining the simple motion detector class.
#RASPBERRY PI 3 XEOMA 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.
#RASPBERRY PI 3 XEOMA CODE#
Looking for the source code to this post? Jump Right To The Downloads Section Multiple cameras with the Raspberry Pi and OpenCV
