ORB Feature Detection in Python

Featured Img ORB Feature Detection

Hello there fellow coder, in this tutorial, we will see what is ORB feature detector is and how can we implement it in Python. ORB stands for Oriented FAST and rotated BRIEF.

Also read: Image Thresholding in Python – An Easy and Quick Guide

Introduction to ORB Feature Detection

Oriented FAST and rotated BRIEF (ORB) is a fast robust local feature detector that was first presented by Ethan Rublee et al. in 2011, and is used in computer vision tasks such as object recognition or 3D reconstruction.

Sample Multiscaled Image Pyramid
Sample Multiscaled Image Pyramid

ORB uses a modified version of the FAST keypoint detector and BRIEF descriptor. In this, the FAST features aren’t scale-invariant and rotation invariant. In order to make FAST scare invariant, we make use of a multi-scale pyramid. The ORB detects features at each level for better accuracy.


Implementing ORB Feature Detection in Python

When it comes to ORB Feature detection we make use of some direct functions to read the image, detect and compute ORB features and then draw the detected key points into the image.

In order to show the image, we make use of the same old imshow function of the OpenCV library. The code is mentioned below, hope you are clear with the steps taken.

import cv2

orb=cv2.ORB_create()
img=cv2.imread("selena.jpg",1)

kp, des = orb.detectAndCompute(img, None)
imgg=cv2.drawKeypoints(img, kp, None)

img = cv2.resize(img, (300, 300))  
imgg = cv2.resize(imgg, (300, 300))  

cv2.imshow("Original Image",img)
cv2.imshow("ORB Feature Detection on Image",imgg)

cv2.waitKey(0)

cv2.destroyAllWindows()

Outputs #1

1.1 Original Image Chosen

Original Image Face Detection
Original Image Face Detection

1.2 After Feature Detection

ORB Face Detection Output Image
ORB Face Detection Output Image

Sample Output #2

2.1 Original Image Chosen

Original Image Face Detection Image2
Original Image Face Detection Image2

2.2 After Feature Detection

ORB Face Detection Output Image2
ORB Face Detection Output Image2

Conclusion

So as you can see, that the major features are getting detected by our model. You can try out the same algorithm using your own personal images as well. And get amazed by the results of the model. Hope you liked the tutorial!

Thank you for reading!