I have an image like this:
When i try to use any of the corner detection algorithms i get corners like this:
however i want to corners of the rectangle.
How can i get rid of those corners that i do not want.
and here is my code
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread("/home/mkmeral/Desktop/opencv/cropped.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
corners = cv2.goodFeaturesToTrack(gray,4,0.01,10)
corners = np.int0(corners)
for i in corners:
x,y = i.ravel()
cv2.circle(img,(x,y),3,255,-1)
plt.subplot(121),plt.imshow(img)
plt.title('2'), plt.xticks([]), plt.yticks([])
plt.suptitle("CORNERS")
cv2.imwrite("/home/mkmeral/Desktop/opencv/corners.png", img)
plt.show()
Here is the whole image, i cropped the image to make it smaller.
This is where i need corners to be: