I\'m using the selective search here: http://koen.me/research/selectivesearch/ This gives possible regions of interest where an object might be. I want to do some processing
Opencv appears to have issues drawing to numpy arrays that have the data type np.int64, which is the default data type returned by methods such as np.array and np.full:
>>> canvas = np.full((256, 256, 3), 255)
>>> canvas
array([[255, 255, 255],
[255, 255, 255],
[255, 255, 255]])
>>> canvas.dtype
dtype('int64')
>>> cv2.rectangle(canvas, (0, 0), (2, 2), (0, 0, 0))
Traceback (most recent call last):
File "", line 1, in
TypeError: Layout of the output array img is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)
The solution is to convert the array to np.int32 first:
>>> cv2.rectangle(canvas.astype(np.int32), (0, 0), (2, 2), (0, 0, 0))
array([[ 0, 0, 0],
[ 0, 255, 0],
[ 0, 0, 0]], dtype=int32)