Live camera edge detection — computer vision in the browser

Run computer vision on your webcam in real time. OpenCV’s cv2.VideoCapture(0) reads frames in the browser (client-side — nothing is uploaded) and this demo shows the live edges via cv2.Canny. Press Run and allow the camera when prompted.

Live camera edge detection — example output

Example code (Python / OpenCV)

import cv2

# The camera starts automatically on Run — allow access when prompted.
cap = cv2.VideoCapture(0)

while True:
    ret, frame = cap.read()
    if not ret:
        print("No camera frame — allow camera access when prompted.")
        break

    cv2.imshow("camera", frame)

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.imshow("edges", cv2.Canny(gray, 80, 160))

    if cv2.waitKey(1) == 27:  # Esc / Stop
        break

More computer-vision techniques →