diegoaguilar
diegoaguilar

Reputation: 8376

How to properly detect corners using Harris detector with OpenCV?

I'm testing some image processing to obtain minutiae from digital fingerprints. I'm doing so far:

  1. Equalize histogram
  2. Binarize
  3. Apply Zhang-Suen algorithm for lines thinning (this is not working properly).
  4. Try to determine corners in thinned image and show them.

So, the modifications I'm obtaining are:

enter image description here enter image description here enter image description here enter image description here

However, I can't get to obtain possible corners in the last image, which belongs to thinned instance of Mat object.

This is code for trying to get corners:

corners_image = cornerHarris(thinned,1,1,0.04)
corners_image = dilate(corners_image,None)

But trying imshow on the resulting matrix will show something like:

enter image description here

a black image.

How should I determine corners then?

Upvotes: 1

Views: 4460

Answers (1)

akarsakov
akarsakov

Reputation: 2154

Actually cv::cornerHarris returns corener responses, not corners itself. Looks like responses on your image is too small.

If you want to visualize corners you may get responses which are larger some threshold parameter, then you may mark this points on original image as follows:

corners = cv2.cvtColor(thinned, cv2.COLOR_GRAY2BGR)
threshold = 0.1*corners_image.max()
corners [corners_image>threshold] = [0,0,255]
cv2.imshow('corners', corners)

Then you can call imshow and red points will correspond to corner points. Most likely you will need to tune threshold parameter to get results what you need.

See more details in tutorial.

Upvotes: 3

Related Questions