Harris corner detection — computer vision in the browser

Harris corner detection finds points where the image changes sharply in every direction — stable landmarks for tracking and matching in computer vision. This fetches a real street photo and marks the strongest corners with cv2.cornerHarris. Run it live and tweak the sensitivity.

Harris corner detection — example output

Example code (Python / OpenCV)

"""
Harris corner detection

Harris corner detection finds points where the image changes sharply in every direction — stable landmarks for tracking and matching in computer vision. This fetches a real street photo and marks the strongest corners with cv2.cornerHarris. Run it live and tweak the sensitivity.
"""

import cv2
import requests
import numpy as np

# A real photo, fetched live from the web — nothing is uploaded
url = "https://images.unsplash.com/photo-1543872084-c7bd3822856f?w=480&q=70"
# no-cache: always fetch a fresh copy so a stale browser-cache entry can't break decoding
resp = requests.get(url, headers={"Cache-Control": "no-cache"})
img = cv2.imdecode(np.frombuffer(resp.content, np.uint8), cv2.IMREAD_COLOR)

gray = np.float32(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY))
dst = cv2.cornerHarris(gray, 2, 3, 0.04)   # blockSize, ksize, k
img[dst > 0.01 * dst.max()] = (0, 0, 255)  # mark strong corners
cv2.imshow("Harris corners", img)

More computer-vision techniques →