Let us now see what the ORB feature detection is? and its implementation using python
Oriented FAST and Rotated BRIEF(ORB):
ORB is an acronym that stands for Oriented FAST and Rotated BRIEF. Opencv Labs created ORB in 2011, which was a fantastic alternative to SIFT and SURF. It is speedier and has a lower computational cost. It is not patented, unlike SIFT and SURF.
ORB employs a modified version of the FAST keypoint detector as well as the BRIEF description. FAST characteristics are not scale-invariant or rotation-invariant.
As a result, in order to be scale-invariant, ORB employs a multi-scale pyramid. A multiscale pyramid is made up of numerous levels, each of which contains a downsampled reproduction of the previous layer’s image. ORB identifies features at all levels and scales.
Each keypoint is assigned an orientation (left or right) based on the change in intensities around it. As a result, ORB is likewise a rotation invariant.
Visit Opencv’s official ORB documentation to learn more about ORB Feature detection.
- Rotate an Image by an Angle in Python
- Python Program to Print Inverted Pyramid Star Pattern
- Python Program to Print Pyramid Star Pattern
ORB Feature Detection in Python
Let us take the below image as an Example:
Given original image
Approach:
- Import cv2 module using the import keyword.
- Read the image using the imread() function by passing the image path as an argument to it.
- Drawing the key points to get orb image.
- Adjust the image dimensions(width, height) of the given image using the resize() function.
- Adjust the image dimensions(width, height) of the ORB feature detected image using the resize() function.
- Display the given original image using the imshow() function.
- Display the ORB feature detected image using the imshow() function.
- The Exit of the Program.
Below is the implementation:
# Import cv2 module using the import keyword import cv2 orb=cv2.ORB_create() # Read the image using the imread() function by passing the image path as an argument to it gvn_image=cv2.imread(r"C:\Users\vicky\Downloads\ab.jpg",1) kp, des = orb.detectAndCompute(gvn_image, None) #Drawing the key points to get orb image orb_image=cv2.drawKeypoints(gvn_image, kp, None) # Adjust the image dimensions(width, height) of the given image using the resize() function gvn_image = cv2.resize(gvn_image, (300, 300)) # Adjust the image dimensions(width, height) of the ORB feature detected image using the resize() function orb_image = cv2.resize(orb_image, (300, 300)) # Display the given original image using the imshow() function cv2.imshow("Original Image",gvn_image) # Display the ORB feature detected image using the imshow() function cv2.imshow("ORB Feature Detection on Image",orb_image) cv2.waitKey(0) cv2.destroyAllWindows()
Output: