Skip to content
Advertisement

Harris corner detector at different rotations

I am using the opencv implementation of Harris Corner detection in python. My question is regarding the behaviour shown in the gif below – as the image is rotated the corners stop being detected (at various rotations). The full code:

JavaScript

based on this.

enter image description here

The image used can be found here. It is perhaps not so clear from the gif (more clear if you run the code), but the corners are detected when the grid lines are horizontal/vertical.

If the blocksize parameter is increased, we can get the desired behaviour (to detect corners at all rotations).

Question – How can the behaviour shown in the gif be explained?

Advertisement

Answer

Updated:

Use goodFeaturesToTrack() instead of using the manual code to retrieve the corners from the Harris response map.

You will have to adapt the blockSize and qualityLevel to your use case if you want to have correct results with OpenCV.

Left is DIPlib, right is OpenCV results.

enter image description here


DIPlib code:

JavaScript

OpenCV code:

JavaScript

Old:

Description of the algorithm

This paper analyses the implementation of the Harris corner detector.

@article{ipol.2018.229,

JavaScript

}

The algorithm is the following:

enter image description here

Step 1 is not included in the original paper.


OpenCV Harris corner detection implementation


Scikit-image corner detection implementation

The code is straightforward:

JavaScript

with structure_tensor():

JavaScript

and _compute_derivatives():

JavaScript

OpenVX Harris corner detection specifications

It can be found here.

From these specifications, vendors can ship custom implementation optimized for their platform. For instance, the ARM compute library.


Comparison between OpenCV and Scikit-image.

  • Versions used:
JavaScript
  • Harris parameter k=0.04
  • OpenCV Harris function parameters that are modified, default values for the experiments are: blockSize=3 and ksize=1
  • Scikit-image Harris function parameter that is modified, default value for the experiment: sigma=1
  • Left: OpenCV results; Right: Scikit-image results

Sudoku image

  • default parameters:

enter image description here

  • OpenCV: blockSize=7, apertureSize=3 ; Scikit-image: sigma=5:

enter image description here

Repeatability rate can be computed, but not sure that my code is totally correct:

enter image description here

Distance threshold is 5.

From my experiments, it looks like Scikit-image yields better corner location accuracy.

Blox image

  • default parameters:

enter image description here

  • OpenCV: blockSize=3, apertureSize=3 ; Scikit-image: sigma=3:

enter image description here

OP Sudoku image

  • default parameters:

enter image description here

  • OpenCV: blockSize=7, apertureSize=3 ; Scikit-image: sigma=7:

enter image description here

Calibrator image

  • default parameters:

enter image description here


Code is here.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement