Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a curve point on a line?

Tags:

python

opencv

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 = enter image description here

result = enter image description here

like image 312
jony woong Avatar asked Dec 05 '25 18:12

jony woong


1 Answers

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:

enter image description here

For more details please check these docs:

Shi-Tomasi Corner Detector

Harris Corner Detection

like image 110
MohammadHosseinZiyaaddini Avatar answered Dec 08 '25 06:12

MohammadHosseinZiyaaddini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!