This used to work:
cv2.rectangle(image, (top,left), (bottom,right), color=color_tuple, thickness=2)
where image is a nxmx3 array of np.uint8 values and color_tuple consisted of a 3 tuple of np.uint8 values, e.g. (2,56,135). Now it produces this error raised in my own code (not the Numpy or OpenCV code):
Exception has occurred: TypeError
Argument given by name ('color') and position (3)
Removing the names from the arguments:
cv2.rectangle(image, (top,left), (bottom,right), color_tuple, 2)
Produces this error:
TypeError: function takes exactly 4 arguments (2 given)
I believe both errors are related to the overridden rectangle function in openCV's source code where it looks for an image followed by a pair of tuples. If it can't find it, it tries to use an overridden function that accepts an image and a rectangle tuple. So the traceback is not representative of the error, but I can't figure out why the numpy types aren't accepted anymore. I tried np.int16, int (which casts it as a np.int64). I could only get it to run by casting the array as python native ints with the tolist() function.
color_tuple = tuple(np.array(np.random.random(size=3)*255, dtype=np.int).tolist())
What caused this? Are there other places OpenCV where numpy datatypes don't work?
Python: 3.6.9
OpenCV: 4.5.1
Numpy: 1.19.5
IDE: VSCode