Haris corner detection
Haris corner detection is a method in which we can detect the corners of the image by sliding a slider box all over the image by finding the corners and it will apply a threshold and the corners will be marked in the image. This algorithm is mainly used to detect the corners of the image.
Syntax:
cv2.cornerHarris(image, dest, blockSize, kSize, freeParameter, borderType)
Parameters:
- Image – The source image to detect the features
- Dest – Variable to store the output image
- Block size – Neighborhood size
- Ksize – Aperture parameter
- Border type: The pixel revealing type.
Example: Feature detection and matching using OpenCV
Python3
# Importing the libraries import cv2 import numpy as np # Reading the image and converting the image to B/W image = cv2.imread( 'book.png' ) gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) gray_image = np.float32(gray_image) # Applying the function dst = cv2.cornerHarris(gray_image, blockSize = 2 , ksize = 3 , k = 0.04 ) # dilate to mark the corners dst = cv2.dilate(dst, None ) image[dst > 0.01 * dst. max ()] = [ 0 , 255 , 0 ] cv2.imshow( 'haris_corner' , image) cv2.waitKey() |
Output:
Feature detection and matching with OpenCV-Python
In this article, we are going to see about feature detection in computer vision with OpenCV in Python. Feature detection is the process of checking the important features of the image in this case features of the image can be edges, corners, ridges, and blobs in the images.
In OpenCV, there are a number of methods to detect the features of the image and each technique has its own perks and flaws.
Note: The images we give into these algorithms should be in black and white. This helps the algorithms to focus on the features more.
Image in use: