Hi,
I am trying to implement the new cv2.text.detectTextSWT() algorithm described here in the opencv docs: OpenCV: cv::text Namespace Reference,
But I am seeing an error with the underlying C++ code.
Here is my code (python):
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
rects, draw, chainBBs = cv2.text.detectTextSWT(img, True)
for rect in rects:
cv2.rectangle(vis, rect, (255, 255, 255), 2)
cv2.imshow("", img)
cv2.waitKey(0)
And the error is:
rects = cv2.text.detectTextSWT(vis, True)
cv2.error: Unknown C++ exception from OpenCV code
Any ideas? My image is a numpy array, and changing it to BGR, GRAY or RGB doesn’t seem to help.
For some reason running img = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 15, 35) before the code example avoids the error? I’m using uint8 as the array dtype, int32 and uint32 didn’t seem to help.
Edit: It seems to only work for me when the image is binarised AND in RGB format, which is very strange.