Can someone explain to me why am I getting the error? and how to fix it? I'm using a pre called function mything which uses the hough transform to find the circle coordinates (x,y,r)
I then introduce the c and z variables as the position of the circle centre with respect to the centre of the camera image to move a robot ( not related to the error). Using the original keypoints I'm unable to draw the circle matches on the image. Apparently there is an error with the cv.draw key points function Thanks in Advance!
import cv2
def mything(img,thresh,r):
minR = r
CannyHighT = 50
min_points = 15 #param2
img_1= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#img3 = cv2.inRange(img_1, thresh, 255)
circles = cv2.HoughCircles(img_1,cv2.HOUGH_GRADIENT, 1, 2*minR, param1=CannyHighT,
param2=min_points, minRadius=minR, maxRadius=220)
keypoints = mything(img,200,50)
i = 0
if keypoints is not None:
for keypoint in keypoints[0,:]:
c= keypoint[0]-320
z=keypoint[1]-240
print("id:%i coord=(%0.0f, %0.0f)" % (i, c, z))
i += 1
#----------------------------------------------
# Display the detection to the user (reference image and camera image side by side, with detection results)
if DISPLAY_RESULT:
i=0
# Draw detected blobs and their id
for keypoint in keypoints[0,:]:
img_matches = cv.drawKeypoints(img, (keypoint[0], keypoint[1]), None, (0, 255, 0), cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv.putText(img_matches, str(i), (int(x), int(y)), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 1, cv.LINE_AA)
cv.circle(img_matches, (int(x), int(y)), 1, (0, 0, 255), 15)
```
Processing image 0 id:0 coord=(-6, 10) Traceback (most recent call last): File "c:/Users/Noore/AppData/Local/Temp/Prog5_3.py", line 117, in img_matches = cv.drawKeypoints(img, (keypoint[0], keypoint[1]), None, (0, 255, 0), cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'drawKeypoints'
Overload resolution failed:
- Can't parse 'keypoints'. Sequence item with index 0 has a wrong type
- Can't parse 'keypoints'. Sequence item with index 0 has a wrong type