What is a dense feature detector?
In order to extract a meaningful amount of information from the images, we need to make sure our feature extractor extracts features from all parts of a given image. Consider the following image:
If you extract features using a feature extractor as we did in Chapter 5, Extracting Features from an Image, it will look like this:
If you used to use the cv2.FeaturetureDetector_create("Dense")
detector, unfortunately, that was removed from OpenCV 3.2 onwards, so we would need to implement our own one iterating over the grid and obtaining the keypoints:
We can control the density as well. Let's make it sparse:
By doing this, we can make sure that every single part in the image is processed. Here is the code to do it:
import sys import cv2 import numpy as np class DenseDetector(): def __init__(self, step_size=20, feature_scale=20, img_bound=20): # Create a dense feature detector self.initXyStep = step_size self.initFeatureScale = feature_scale...