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: 

Similar Reads

Method 1: 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....

Method 2: Shi-Tomasi corner detection

...

Method 3: SIFT (Scale-Invariant Feature Transform)

Shi and Tomasi came up with a different corner detection algorithm which is mostly similar to the Haris corner detection algorithm in which the only difference will be the kernel value in which we can find only the n strongest corners of the image. This can greatly help while we need only the limited and very important features of the image....

Method 4: FAST algorithm for corner detection

...

Method 5: ORB (Oriented FAST and Rotated Brief)

While Haris and shi-Tomasi are the algorithms to detect the corners of the image. SIFT is one of the important algorithms that detect objects irrelevant to the scale and rotation of the image and the reference. This helps a lot while we are comparing the real-world objects to an image though it is independent of the angle and scale of the image. This method will return the key points of the images which we need to mark in the image....