
- OpenCV Python Tutorial
- OpenCV Python - Home
- OpenCV Python - Overview
- OpenCV Python - Environment
- OpenCV Python - Reading Image
- OpenCV Python - Write Image
- OpenCV Python - Using Matplotlib
- OpenCV Python - Image Properties
- OpenCV Python - Bitwise Operations
- OpenCV Python - Shapes and Text
- OpenCV Python - Mouse Events
- OpenCV Python - Add Trackbar
- OpenCV Python - Resize and Rotate
- OpenCV Python - Image Threshold
- OpenCV Python - Image Filtering
- OpenCV Python - Edge Detection
- OpenCV Python - Histogram
- OpenCV Python - Color Spaces
- OpenCV Python - Transformations
- OpenCV Python - Image Contours
- OpenCV Python - Template Matching
- OpenCV Python - Image Pyramids
- OpenCV Python - Image Addition
- OpenCV Python - Image Blending
- OpenCV Python - Fourier Transform
- OpenCV Python - Capture Videos
- OpenCV Python - Play Videos
- OpenCV Python - Images From Video
- OpenCV Python - Video from Images
- OpenCV Python - Face Detection
- OpenCV Python - Meanshift/Camshift
- OpenCV Python - Feature Detection
- OpenCV Python - Feature Matching
- OpenCV Python - Digit Recognition
- OpenCV Python Resources
- OpenCV Python - Quick Guide
- OpenCV Python - Resources
- OpenCV Python - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
OpenCV Python - Feature Matching
OpenCV provides two techniques for feature matching. Brute force matching and FLANN matcher technique.
Example
Following example uses brute-force method
import numpy as np import cv2 img1 = cv2.imread('lena.jpg') img2 = cv2.imread('lena-test.jpg') # Convert it to grayscale img1_bw = cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY) img2_bw = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) orb = cv2.ORB_create() queryKeypoints, queryDescriptors = orb.detectAndCompute(img1_bw,None) trainKeypoints, trainDescriptors = orb.detectAndCompute(img2_bw,None) matcher = cv2.BFMatcher() matches = matcher.match(queryDescriptors,trainDescriptors) img = cv2.drawMatches(img1, queryKeypoints, img2, trainKeypoints, matches[:20],None) img = cv2.resize(img, (1000,650)) cv2.imshow("Feature Match", img)
Output

Advertisements