About: time passing when in mood, do crazy stuff with friends and occasionally with gaming stuff and arduino and beagle bone

I'll keep the intro short, as the title itself suggests what the main purpose of the instructable is. In this step-by-step instructable, I will explain you how to connect multiple cameras like 1-pi cam and at least one USB camera, or 2 USB cameras. The setup will allow us to access all the streams simultaneously, and perform motion detection on each one of them. The best part about this is, openCV is running in real-time, (or near real-time, depending on the number of cameras you have attached). It can be used for home surveillance.


1. Multi-cam setup

2. Defining the simple motion detector, accessing the streams

4. End Result

Step 1: Multi-cam Setup

When building a Raspberry Pi setup to leverage multiple cameras, you have two options:

Simply use multiple USB webcams.

Or use one Raspberry Pi camera module and at least one USB web camera.

We have used a Logitech c920 web camera.

The raspberry pi has one internal camera port, but if you want to use multiple raspberry pi cameras instead of a USB camera, you have to get a shield.

Now let us consider a 2 camera setup with one pi-cam and one USB camera. The output would be like the one in image_2.

In the remaining part of this post, we will be defining the simple motion detector code for a single camera first and then implement it to multiple cameras.

Step 2: Defining the Simple Motion Detector

In this section, we'll define a simple python code to detect objects. To maintain efficiency lets consider only one object is moving in one camera view.

all the code files are attached in my Github link:

Step 3: End Result

Raspberry Pi Contest 2020

Participated in the
Raspberry Pi Contest 2020