PyImageSearch / imutils

A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using Multiple Cameras

oladayoaluke opened this issue · comments

Currently, code fails using two cameras because you are not handling multiple cameras. PiCamera already implemented this, so all you need to do is to add camera_id parameter and pass it into picamera initialization. Its as simple as that. I did it to use two cameras, it will be nice to add it to the repo.

Step 1
sudo nano /usr/local/lib/python3.7/dist-packages/imutils/video/pivideostream.py

Step 2
def init(self, resolution=(320, 240), framerate=32, camera_id=0, **kwargs):
# initialize the camera
self.camera = PiCamera(camera_id)

Step 3
from imutils.video.pivideostream import PiVideoStream

class MyVideoCamera(object):
def init(self, camera_id, flip = False):
self.vs = PiVideoStream(camera_id=camera_id)

It worked!