I have written the following code in OpenCV in V.S. Code on Mac. I have assigned (pts1) pixel values of certains points in the image (img). But, when I try to circle the points I am getting this error:-
Traceback (most recent call last):
cv.circle(img, (pts1[0][0], pts1[0][1]), 5, (0,0,255), cv.FILLED)
cv2.error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'circle'
> Overload resolution failed:
> - Can't parse 'center'. Sequence item with index 0 has a wrong type
> - Can't parse 'center'. Sequence item with index 0 has a wrong type
Any suggestions on how can I resolve this issue? Do let me know if you have any concerns regarding the code. Thanks for the help!
import cv2 as cv
import numpy as np
# Cards Image
img = cv.imread('Images/cards.jpg')
cv.imshow('Cards Image', img)
# Step 1. Note down the pixel value of all the 4 corners from the image
pts1 = np.float32([[657,122],[738,235],[478,249],[559,362]])
print(pts1)
cv.circle(img, (pts1[0][0], pts1[0][1]), 5, (0,0,255), cv.FILLED)
# i = 0
# for i in range(4):
# cv.circle(img, (pts1[i][0], pts1[i][1]), 5, (0,0,255), cv.FILLED)
cv.waitKey(0)
The problem is just parsing the (x, y)
or the (pts1[0][0], pts1[0][1])
to integers you just have to do the following (int(pts1[0][0]), int(pts1[0][1]))
in the circle
function
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