In this chapter, you learned how to detect faces in video streams. The same principle applies to detecting faces in images, only this time we are applying our Haar cascades to individual frames of a stream rather than an image we loaded from disk.

In general, you can follow the same pattern when applying computer vision techniques to video streams. Start by obtaining the next frame from your stream, process it like you would a normal image, and then record the result.

Increase your FPS processing rate

Anytime you work with video streams, you should consider applying threading to reduce I/O latency and therefore increase the number of frames you can process per second.

The following blog post details how to utilize threading to improve the video processing sequence introduced in this chapter:

http://www.pyimagesearch.com/2015/12/21/increasing-webcam-fps-with-python-and-opencv/

If you are using a Raspberry Pi camera module rather than a USB or built-in webcam, you should refer to this tutorial:

http://www.pyimagesearch.com/2015/12/28/increasing-raspberry-pi-fps-with-python-and-opencv/

Finally, if you want your code to work with both built-in/USB webcams and the Raspberry Pi, I have provided a VideoStream  class that is compatible with both types of cameras out of the box:

http://www.pyimagesearch.com/2016/01/04/unifying-picamera-and-cv2-videocapture-into-a-single-class-with-opencv/

Utilize multiple cameras

I’d also like to mention that by utilizing threading, you can access multiple cameras from the same Python script. The following tutorial demonstrates how to accomplish this:

http://www.pyimagesearch.com/2016/01/18/multiple-cameras-with-the-raspberry-pi-and-opencv/

0% Complete
0/18 Steps