python opencv TypeError: Layout of the output array incompatible with cv::Mat
My own solution was simply to ask a copy of original array...(god & gary bradski knows why...)
im = dbimg[i]
bb = boxes[i]
m = im.transpose((1, 2, 0)).astype(np.uint8).copy()
pt1 = (bb[0],bb[1])
pt2 = (bb[0]+bb[2],bb[1]+bb[3])
cv2.rectangle(m,pt1,pt2,(0,255,0),2)
Another reason may be that the array is not contiguous. Making it contiguous would also solve the issue
image = np.ascontiguousarray(image, dtype=np.uint8)
The solution was to convert found
first to a numpy array, and then to recovert it into a list:
found = np.array(found)
boxes = cv2.groupRectangles(found.tolist(), 1, 2)