i want to detect all corner and start , end point on line. i can detect start and end point but curve can't detect. this is my code
from scipy.ndimage import generic_filter
def lineEnds(P):
return 255 * ((P[4]==255) and np.sum(P)==510)
image = cv2.imread("./dataset/test.jpg" , cv2.COLOR_RGB2GRAY)
result = generic_filter(image , lineEnds, (3, 3))
image = 
result = 
You can detect corners with the OpenCV too
import cv2
image = cv2.imread('./test.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Detect corners in the image
corners = cv2.goodFeaturesToTrack(gray, 500, qualityLevel=0.01, minDistance=20)
for c in corners:
x, y = c.reshape(2)
print(x, y)
# draw a circle around the detected corner
cv2.circle(image, (x, y), radius=4, color=(0, 255, 120), thickness=2)
cv2.imshow("Result", image)
cv2.waitKey(0)
Result:

For more details please check these docs:
Shi-Tomasi Corner Detector
Harris Corner Detection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With