I was trying to detect all the corners in the image using harris corner detection in opencv(python). But due to the thickness of the line , I am getting multiple corners in a single corner . Is there something I can do to make this right.
code
import numpy as np
import cv2 as cv
filename = 'Triangle.jpg'
img = cv.imread(filename)
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv.cornerHarris(gray,2,3,0.04)
#result is dilated for marking the corners, not important
dst = cv.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.01*dst.max()]=[0,0,255]
cv.imshow('dst',img)
if cv.waitKey(0) & 0xff == 27:
cv.destroyAllWindows()


If your expectation is to obtain a single corner point at every line intersection, then the following is a simple approach.
Current scenario:
In the above, there are many (supposedly) corner points close to each other.
Approach:
The idea now is to preserve only one point that is in close proximity to each other, while discarding the rest. To do so, I calculate the distance of each corner to every other and keep those that exceed a threshold.
Suggestions:
To get more accurate result you can try finding the mean of all the points within a certain proximity. These would coincide close to the intersection of lines.