Traceback most recent call last File fCXYPython图像识别testpy line 27 in module drawtextlocationtextfill=000 File CUsersDELLAppDataLocalProgramsPythonPython39libsite-packagesPILImageDrawpy line
This error occurs when trying to convert an array to a scalar value. It seems that the variable xy in the draw_text function contains an array with a length greater than 1, which is not compatible with the int() function.
To fix this error, you need to ensure that the xy variable is a scalar value or an array with a length of 1 before passing it to the int() function. You can do this by checking the length of the xy variable and handling it accordingly.
Here is an example of how you can modify the code to handle this error:
if len(xy) == 1:
coord.append(int(xy[0]))
else:
# Handle the case when xy has a length greater than 1
# For example, you can take the first element of xy and convert it to an integer
coord.append(int(xy[0]))
By checking the length of xy and handling it accordingly, you can ensure that only scalar values or arrays with a length of 1 are passed to the int() function, avoiding the TypeError
原文地址: https://www.cveoy.top/t/topic/iF0H 著作权归作者所有。请勿转载和采集!