Feature detection (SIFT, SURF, ORB) – OpenCV 3.4 with python 3 Tutorial 25
We’re going to learn in this tutorial how to find features on an image.
We have thre different algorythms that we can use:
Each one of them as pros and cons, it depends on the type of images some algorithm will detect more features than another.
SIFT and SURF are patented so not free for commercial use, while ORB is free.SIFT and SURF detect more features then ORB, but ORB is faster.
First we import the libraries and load the image:
import cv2 import numpy as np img = cv2.imread("the_book_thief.jpg", cv2.IMREAD_GRAYSCALE)
We then load one by one the three algorythms.
sift = cv2.xfeatures2d.SIFT_create() surf = cv2.xfeatures2d.SURF_create() orb = cv2.ORB_create(nfeatures=1500)
We find the keypoints and descriptors of each spefic algorythm.
A keypoint is the position where the feature has been detected, while the descriptor is an array containing numbers to describe that feature.
When the descriptors are similar, it means that also the feature is similar. You can see this tutorial to understand more about feature matching.
keypoints_sift, descriptors = sift.detectAndCompute(img, None) keypoints_surf, descriptors = surf.detectAndCompute(img, None) keypoints_orb, descriptors = orb.detectAndCompute(img, None)
We finally draw the keypoints on the image. In this case we are drawing only the keypoints detected from the orb algorythm.
img = cv2.drawKeypoints(img, keypoints, None) cv2.imshow("Image", img) cv2.waitKey(0) cv2.destroyAllWindows()
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Opencv Beginner Tutorial
- 1) Loading images
- 2) Loading Video and Webcam
- 3) Drawing and writing on images
- 4) Basic operations on images
- 5) Add images and Threshold
- 6) Blending images
- 7) Bitwise Operators
- 8) Trackbars
- 9) Object detection using HSV Color space
- 10) Basic Thresholding
- 11) Histograms
- 12) Basic geometric transformations
- 13) Perspective transformation
- 14) Affine transformation
- 15) Adaptive thresholding5
- 16) Smoothing images
- 17) Morphological transformation
- 18) Edge detection
- 19) Find and Draw Contours
- 20) Template matching
- 21) Lines detection with Hough Transform
- 22) Corners detection
- 23) Image Pyramids
- 24) Image Pyramids (Blending and reconstruction)
- 25) Feature detection (SIFT, SURF, ORB)
- 26) Feature Matching (Brute-Force)
- 27) Mouse Events
- 28) Histogram and Back Projection
- 29) Object tracking with Mean-shift
- 30) Object tracking with Camshift
- 31) Optical Flow with Lucas-Kanade method
- 32) Background Subtraction
- 33) k-Nearest Neighbour classification
- 34) Object tracking using Homography
- 35) Fourier Transform
- 36) Knn handwritten digits recognition
- 37) Face detection using Haar Cascades
- Train YOLO to detect a custom object (online with free GPU)
- YOLO object detection using Opencv with Python
- Feature detection (SIFT, SURF, ORB) – OpenCV 3.4 with python 3 Tutorial 25
- How to install Python 3 and Opencv 4 on Windows
- Detecting colors (Hsv Color Space) – Opencv with Python
- How to install Dlib for Python 3 on Windows
- Check if two images are equal with Opencv and Python
- Simple shape detection – Opencv with Python 3