-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: only size-1 arrays can be converted to Python scalars #18
Comments
Hello @bhavyabpk, Can you try with Python 3 ? I didn't really test with Python 2.7. |
Yes it is working with python 3 but before the class name which is being
printed on the box, there are 3 question mark coming.
Like my class name is Tank, so on the bounding box its written ???Tank.
I am unable to figure it out why its is so. I think confidence must be
coming at its place but there are question marks. I haven't done any
changes in the code.
…On Tue 9 Jul, 2019, 12:28 PM Arun Ponnusamy, ***@***.***> wrote:
Hello @bhavyabpk <https://github.com/bhavyabpk>, Can you try with Python
3 ? I didn't really test with Python 2.7.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18?email_source=notifications&email_token=AH4G2LEOPBKBZQMGZPVWXI3P6QZIXA5CNFSM4H64KVC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZPJPHA#issuecomment-509515676>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AH4G2LGAPBHLRDUITPFBXR3P6QZIXANCNFSM4H64KVCQ>
.
|
The issue could be in reading the class labels from the text file. Try printing the labels before writing on image. Or you can try the example below with cvlib. |
My issue was resolved when I created new classes.names file and wrote the
classes using the keyboard again. For me, it was because there was an
unknown character present in my previous classes.names file which resulted
in "??"
…On Thu, Mar 19, 2020 at 10:27 PM jayeshbhole ***@***.***> wrote:
Hello @bhavyabpk <https://github.com/bhavyabpk>, Can you try with Python
3 ? I didn't really test with Python 2.7.
Or you can replace round( ) with int( ).
Sir, I'm getting the same error with Python 3.7. The change is that I've
take the image with webcam and not from the system itself. Should I change
the type of the image?
Code Snippets:
image = cv2.VideoCapture(0)
image.set(3, 640)
image.set(4, 480)
while True:
_ , img = image.read()
#everything else is the same
draw_prediction(image, confidences[i], int(x), int(y), int(x+w), int(y+h))
plate = img[(y+20):(y+h-20), (x+20):(x+w-20)]
#I've removed the class id as only one object is to be detected
Exact Error:
File "platedet.py", line 100, in
draw_prediction(image, confidences[i], int(x), int(y), int(x+w), int(y+h))
File "platedet.py", line 29, in draw_prediction
cv2.rectangle(img, (x,y), (x_plus_w,y_plus_h), color, 15)
TypeError: only size-1 arrays can be converted to Python scalars
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH4G2LHMIOCPZSWTBL5AAITRIJFG3ANCNFSM4H64KVCQ>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Traceback (most recent call last):
File "yolodetect2.py", line 98, in
draw_prediction(image, class_ids[i], confidences[i], round(x), round(y), round(x+w), round(y+h))
File "yolodetect2.py", line 39, in draw_prediction
cv2.rectangle(img, (x,y), (x_plus_w,y_plus_h), color, 2)
TypeError: only size-1 arrays can be converted to Python scalars
ubuntu version 16.04
python version 2.7.12
opencv version 4.1.0
The text was updated successfully, but these errors were encountered: