I am trying to find centroid of circular shape with the help of OpenCV Sift for my project.
After finding centroid try to fit a encoding ring to detect type of marker. The SIFT algorithm is the best for my project, since it is scalar and rotation invariant. It seems to detect the keypoint of centroid of object and i am trying to get the coordinates of it.
import cv2
import numpy as np
def findSift(img, gray, draw=True):
sift = cv2.SIFT_create(10)
kp = sift.detect(gray, None)
if draw:
cv2.drawKeypoints(img, kp, img)
kp_coordinates = cv2.KeyPoint_convert(kp)
return kp_coordinates
if __name__ == "__main__":
img = cv2.imread('Test.jpg')
print(img.shape[:2])
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
Array_Cooridinates = findSift(img,gray)
cv2.imshow('img',img)
cv2.waitKey(0)
Image Resolution: (849, 734)
Array of coordinates of keypoints detected:
[[346.20126 385.5532 ]
[366.1102 217.0911 ]
[366.1102 217.0911 ]
[482.2291 451.484 ]
[482.2291 451.484 ]
[468.70483 303.86118]
[468.70483 303.86118]
[385.93945 296.0943 ]
[417.37436 445.36234]
[441.80768 377.35934]]
If someone have any reference to my problem, feel free to post it so i can do more research about it.
Thanks for any help here! Have a nice day.