DirkS
Posts: 10371
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: cv2.putText "TypeError: not enough arguments for format

Sun Apr 23, 2017 11:34 am

I think the arguments need to be in brackets:

Code: Select all

('width = %d, height = %d' % (w, h))

DirkS
Posts: 10371
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: cv2.putText "TypeError: not enough arguments for format

Sun Apr 23, 2017 12:25 pm

Does it indicate *where* it expects a float? Does it point to the format (%) statement?

User avatar
Paeryn
Posts: 2986
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: cv2.putText "TypeError: not enough arguments for format

Sun Apr 23, 2017 2:56 pm

supra wrote:

Code: Select all

            cv2.putText(frame, ('width = %d, height = %d' % w, h, (x,y)), font,(0, 255, 0), 2, cv2.LINE_AA)
It looks like you've got the font scale missing, you have the colour straight after the font which is where the error is.

Also you've got the string format wrongly bracketed... You need brackets around the parameters after the %, and you want to close the brackets around the whole string but you have it after the (x,y) parameter...

Code: Select all

            cv2.putText(frame, ('width = %d, height = %d' % (w, h)), (x,y), font, 1, (0, 255, 0), 2, cv2.LINE_AA)
She who travels light — forgot something.

Return to “Graphics programming”