- OpenCV Python - Digit Recognition
- OpenCV Python - Feature Matching
- OpenCV Python - Feature Detection
- OpenCV Python - Meanshift/Camshift
- OpenCV Python - Face Detection
- OpenCV Python - Video from Images
- OpenCV Python - Images From Video
- OpenCV Python - Play Videos
- OpenCV Python - Capture Videos
- OpenCV Python - Fourier Transform
- OpenCV Python - Image Blending
- OpenCV Python - Image Addition
- OpenCV Python - Image Pyramids
- OpenCV Python - Template Matching
- OpenCV Python - Image Contours
- OpenCV Python - Transformations
- OpenCV Python - Color Spaces
- OpenCV Python - Histogram
- OpenCV Python - Edge Detection
- OpenCV Python - Image Filtering
- OpenCV Python - Image Threshold
- OpenCV Python - Resize and Rotate
- OpenCV Python - Add Trackbar
- OpenCV Python - Mouse Events
- OpenCV Python - Shapes and Text
- OpenCV Python - Bitwise Operations
- OpenCV Python - Image Properties
- OpenCV Python - Using Matplotlib
- OpenCV Python - Write Image
- OpenCV Python - Reading Image
- OpenCV Python - Environment
- OpenCV Python - Overview
- OpenCV Python - Home
OpenCV Python Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
OpenCV Python - Feature Detection
In the context of image processing, features are mathematical representations of key areas in an image. They are the vector representations of the visual content from an image.
Features make it possible to perform mathematical operations on them. Various computer vision apppcations include object detection, motion estimation, segmentation, image apgnment etc.
Prominent features in any image include edges, corners or parts of an image. OpenCV supports Haris corner detection and Shi-Tomasi corner detection algorithms. OpenCV pbrary also provides functionapty to implement SIFT (Scale-Invariant Feature Transform), SURF(Speeded-Up Robust Features) and FAST algorithm for corner detection.
Harris and Shi-Tomasi algorithms are rotation-invariant. Even if the image is rotated, we can find the same corners. But when an image is scaled up, a corner may not be a corner if the image. The figure given below depicts the same.
D.Lowe s new algorithm, Scale Invariant Feature Transform (SIFT) extracts the key points and computes its descriptors.
This is achieved by following steps −
Scale-space Extrema Detection.
Keypoint Locapzation.
Orientation Assignment.
Keypoint Descriptor.
Keypoint Matching.
As far as implementation of SIFT in OpenCV is concerned, it starts from loading an image and converting it into grayscale. The cv.SHIFT_create() function creates a SIFT object.
Example
Calpng its detect() method obtains key points which are drawn on top of the original image. Following code implements this procedure
import numpy as np import cv2 as cv img = cv.imread( home.jpg ) gray= cv.cvtColor(img,cv.COLOR_BGR2GRAY) sift = cv.SIFT_create() kp = sift.detect(gray,None) img=cv.drawKeypoints(gray,kp,img) cv.imwrite( keypoints.jpg ,img)
Output
The original image and the one with keypoints drawn are shown below −
This is an original image.
An image given below is the one with keypoints −
Advertisements