ORB: Oriented FAST and Rotated BRIEF
Combination:
Advantages:
Use case: Mobile devices, embedded systems, real-time applications
Steps:
FAST: Features from Accelerated Segment Test
Method:
ORB improvement: Harris measure to rank corners
Problem: BRIEF not rotation invariant
Solution: Compute orientation, rotate BRIEF pattern
Intensity centroid method:
m_pq = Σ x^p × y^q × I(x,y)
C = (m10/m00, m01/m00)
θ = atan2(m01, m10)
Result: Rotation-invariant descriptor
BRIEF: Binary Robust Independent Elementary Features
I(p1) < I(p2)
256 bits: 256 pixel pairs → 256 comparisons
Advantage: Very fast to compute and match (XOR + bit count)
import cv2# create ORB detector#ans: orb = cv2.ORB_create()# detailed parameters#ans: orb = cv2.ORB_create(nfeatures=500, scaleFactor=1.2, nlevels=8, edgeThreshold=31, firstLevel=0, WTA_K=2, scoreType=cv2.ORB_HARRIS_SCORE, patchSize=31, fastThreshold=20)# nfeatures: max keypoints to retain#ans: 500 strongest features# scaleFactor: pyramid scale factor#ans: 1.2 means each level is 1/1.2 = 83% of previous# nlevels: number of pyramid levels#ans: 8 levels for multi-scale detection
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)orb = cv2.ORB_create(nfeatures=1000)# detect keypoints only#ans: keypoints = orb.detect(gray, None)# detect and compute descriptors#ans: keypoints, descriptors = orb.detectAndCompute(gray, None)# descriptor is binary#ans: print(descriptors.shape) # (N, 32) - 32 bytes = 256 bits#ans: print(descriptors.dtype) # uint8
orb = cv2.ORB_create()kp, des = orb.detectAndCompute(gray, None)# simple keypoint drawing#ans: img_kp = cv2.drawKeypoints(img, kp, None, color=(0, 255, 0))# rich keypoints (with size and orientation)#ans: img_kp = cv2.drawKeypoints(img, kp, None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)#ans: circles show scale, lines show orientation
Distance metric: Hamming distance (count differing bits)
Fast matching: XOR operation + bit count
# create ORB matcher (Hamming distance)#ans: bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)# detect in two imagesorb = cv2.ORB_create()kp1, des1 = orb.detectAndCompute(gray1, None)kp2, des2 = orb.detectAndCompute(gray2, None)# match#ans: matches = bf.match(des1, des2)#ans: matches = sorted(matches, key=lambda x: x.distance)
ORB advantages:
SIFT advantages:
Choice: ORB for speed, SIFT for accuracy
Why pyramid?
ORB pyramid:
nlevels=8, scaleFactor=1.2: 8 scales from 100% to ~23%
WTA_K: Number of points in BRIEF test
Options:
Trade-off: Robustness vs speed/memory
# what does ORB stand for?#ans: Oriented FAST and Rotated BRIEF# what detector does ORB use?#ans: FAST corner detector# what descriptor does ORB use?#ans: BRIEF binary descriptor (rotated)# how many bits in ORB descriptor?#ans: 256 bits (32 bytes)# what distance metric for ORB?#ans: Hamming distance (count differing bits)
# why ORB is fast?#ans: binary descriptor, simple comparisons, fast matching# how does ORB handle rotation?#ans: assigns orientation using intensity centroid# what is scaleFactor?#ans: pyramid scale ratio between levels# advantage of binary descriptors?#ans: fast to compute and match (XOR + bit count)# ORB vs SIFT trade-off?#ans: ORB faster but less accurate, SIFT slower but more robust
# create ORB with 2000 features#ans: orb = cv2.ORB_create(nfeatures=2000)# detect and computegray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)#ans: keypoints, descriptors = orb.detectAndCompute(gray, None)# check descriptor shape#ans: print(descriptors.shape) # (N, 32)# create Hamming matcher#ans: bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
# match ORB featuresorb = cv2.ORB_create()kp1, des1 = orb.detectAndCompute(gray1, None)kp2, des2 = orb.detectAndCompute(gray2, None)bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)#ans: matches = bf.match(des1, des2)#ans: matches = sorted(matches, key=lambda x: x.distance)#ans: img_matches = cv2.drawMatches(img1, kp1, img2, kp2, matches[:50], None, flags=2)
# ORB with more pyramid levels#ans: orb = cv2.ORB_create(nlevels=12, scaleFactor=1.2)#ans: 12 levels for wider scale range# draw rich keypointsorb = cv2.ORB_create()kp, des = orb.detectAndCompute(gray, None)#ans: img_kp = cv2.drawKeypoints(img, kp, None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)# ORB with WTA_K=3#ans: orb = cv2.ORB_create(WTA_K=3)#ans: more robust descriptor, larger size
Google tag (gtag.js)