AI Hints
Home›Computer Vision Tutorial›Features and Camera Geometry
Computer Vision · Lesson 10 of 111

Keypoints and Features

Finding what stays the same.

⏱ 2 min read▶ Video at 16:52🎓 Free
Watch this lesson in the Computer Vision courseWatch on YouTube ↗Full Computer Vision course

Take a photo of a building. Walk closer, and take another from a different angle. You'd instantly say that it's the same place, because you recognise distinctive parts. A corner of a window, the top of a door. In the two thousands, researchers gave computers that ability.

Keypoints and Features
From the video: Keypoints and Features
  • Two photos, different angles
  • You recognise distinctive parts
  • Computers learned to do this

What makes a good keypoint?

A good keypoint is easy to find again. A flat wall is useless, because every spot looks alike. An edge is a little better, but you could slide along it. A corner is great, because it's unique in both directions. Then a descriptor summarises the patch around that point, as a list of numbers, so that it can be compared. SIFT and ORB are the famous methods.

Flat areaevery spot alike
Edgecan slide along it
Cornerunique, easy to refind
Descriptora fingerprint of the patch

Finding keypoints

Here's the classic corner detector, and then ORB, which is fast and free to use. Each keypoint gets a descriptor of thirty two bytes. Run it. Green circles mark distinctive spots, on the face, the suit, and the flag, and very few on the flat black background. These points are the anchors for everything in the next few lessons.

keypoints.pypython
import cv2
import matplotlib.pyplot as plt
from skimage import data

gray = cv2.cvtColor(data.astronaut(), cv2.COLOR_RGB2GRAY)

corners = cv2.goodFeaturesToTrack(gray, 200, 0.02, 8)
orb = cv2.ORB_create(400)
points, desc = orb.detectAndCompute(gray, None)

out = cv2.drawKeypoints(gray, points, None, color=(0, 255, 0))
plt.figure(figsize=(5, 5)); plt.imshow(out); plt.axis("off")
plt.tight_layout(); plt.savefig("keypoints.png", dpi=110)
print("Corners:", len(corners))
print("ORB keypoints:", len(points), " descriptor size:", desc.shape[1], "bytes")
Output
Corners: 200
ORB keypoints: 400  descriptor size: 32 bytes

Summary

Good keypoints are unique, and descriptors act as their fingerprints. So what can you do with them? You can recognise the same thing across two very different views.

Key takeaways
  • Corners make good keypoints
  • Descriptors compare patches
  • ORB is fast and free
Next up: Matching Images — the same point in two photos