Hello I am trying to run code that involves drawing a box but keeps returning the error
TypeError: integer argument expected, got float
The first issue in the code that appeared was
def draw_box(Image, x, y, w, h):
cv2.line(Image, (x, y), (x + (w/5) ,y), WHITE, 2)
cv2.line(Image, (x+((w/5)*4), y), (x+w, y), WHITE, 2)
cv2.line(Image, (x, y), (x, y+(h/5)), WHITE, 2)
cv2.line(Image, (x+w, y), (x+w, y+(h/5)), WHITE, 2)
cv2.line(Image, (x, (y+(h/5*4))), (x, y+h), WHITE, 2)
cv2.line(Image, (x, (y+h)), (x + (w/5) ,y+h), WHITE, 2)
cv2.line(Image, (x+((w/5)*4), y+h), (x + w, y + h), WHITE, 2)
cv2.line(Image, (x+w, (y+(h/5*4))), (x+w, y+h), WHITE, 2)
Which I fixed by replacing the division signs with python floor division, though then the next area of box drawing which returns the same Type Error
cv2.rectangle(Image, (Name_X_pos-10, Name_y_pos-25), (Name_X_pos +10 + (len(NAME) * 7), Name_y_pos-1), (0,0,0), -2)
I've tried putting cv2.rectangle(int(Image, (Name_.. only to receive back
TypeError: int() takes at most 2 arguments (5 given)
Any ideas on how to fix this?
int(Image, (Name)..)-- you want to cast the individual numbers as integers, so for e.g.(int(Name_X_pos+10+len(NAME)*7), ...)int(). Just do one number at a time (look carefully at the code I just sent).cv2.rectangle(Image, (int(Name_X_pos-10), int(Name_y_pos-25)), (int(Name_X_pos +10 + (len(NAME) * 7)), int(Name_y_pos-1)), (0,0,0), -2)