Describe the feature and motivation
Overload resolution should check a numpy array's dtype for being object, and in that case emit a useful error message like
numpy array dtype is object, which is not supported. Check array contents.
Additional context
Beginners often have trouble with imread(). It will not throw an exception but return None, silently, and most tutorials don't bother checking for that. Further processing may produce numpy arrays of dtype=object.
img = None # cv.imread("does_not_exist.png")
res = np.hstack([img, img]) # put side by side
cv.imwrite("foo.png", res)
(Source)
Calling imwrite() with a numpy array of dtype=object will throw this mysterious error that says:
cv2.error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'imwrite'
> Overload resolution failed:
> - img data type = 17 is not supported
> - Expected Ptr<cv::UMat> for argument 'img'
(behavior exists with v4.7.0 and v4.6.0 at least)
This does not help. Data type 17 would decode to be CV_8SC3, which this obviously is not. Mentioning the Ptr<cv::UMat> strikes me as irrelevant since the overload resolution already accepted the numpy array, merely complains about its element type.