Skip to content
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

Open
bhavyabpk opened this issue Jul 8, 2019 · 4 comments
Open

Comments

@bhavyabpk
Copy link

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

@arunponnusamy
Copy link
Owner

arunponnusamy commented Jul 9, 2019

Hello @bhavyabpk, Can you try with Python 3 ? I didn't really test with Python 2.7.
Or you can replace round( ) with int( ).

@bhavyabpk
Copy link
Author

bhavyabpk commented Jul 9, 2019 via email

@arunponnusamy
Copy link
Owner

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.
https://github.com/arunponnusamy/cvlib/blob/master/examples/object_detection.py

@bhavyabpk
Copy link
Author

bhavyabpk commented Mar 22, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants