{% from macros import embed %}
This example detects faces in a live camera feed, draws a box around each one, and plots the number of faces seen over time.
Under the hood, OpenCV's Haar cascade scans each frame for contrast patterns. A Haar-like feature compares neighboring image regions:
Here, I(p) is the intensity of pixel p, while R+ and R− are neighboring rectangles whose summed intensities are compared (see Wikipedia's overview of Haar-like features).
Integral images make these sums fast, while the cascade rejects unlikely windows early. Bokeh flips the surviving boxes from OpenCV's top-left origin into its bottom-left plot space and streams them with the RGBA frame.