You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using EasyOCR to make very simple banknote recognition for uni project, using Python and OpenCV. If I understand correctly provided examples, code below:
importcv2importnumpyasnpimporteasyocrcap=cv2.VideoCapture(...)
reader=easyocr.Reader(["en"])
did_read, frame=cap.read()
# some frame preprocessing if necessary - cropping to area of interest, adding filters and thresholdingread_txts=reader.readtext(processed_frame)
should produce result, which I type-hint in my code as:
of course actual result uses lists instead of tuples for bounding box, but this allows slightly better type-checking, since you cannot type-hint list with constant length, but this doesn't really matter.
What does matter, is that it should be possible to use this output directly, to draw result on image using OpenCV:
However on some rare occasions, snippet of code above would throw on cv2.drawContours, with error message: cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\drawing.cpp:2504: error: (-215:Assertion failed) npoints > 0 in function 'cv::drawContours'
On closer inspection in debugger, it seems that when error occurs, reader.readtext(...) returns result in which bounding box points are of type float, and not the expected int (int points are being returned +99% of times):
Of course this can be fixed in user code, which in snipped above would be:
box=np.array(box, dtype=np.int_)
however I feel that either examples in this repository in readme.md and on site https://www.jaided.ai/easyocr/tutorial/ are misleading, showing that only int numbers can be expected in bounding box component of output, or there is some rare bug which results in non-integer output.
The text was updated successfully, but these errors were encountered:
Bounding boxes returned as polys can be returned with float coords.
From the API documentation - "Return horizontal_list, free_list - horizontal_list is a list of regtangular text boxes. The format is [x_min, x_max, y_min, y_max]. free_list is a list of free-form text boxes. The format is [[x1,y1],[x2,y2],[x3,y3],[x4,y4]]."
I'm using EasyOCR to make very simple banknote recognition for uni project, using Python and OpenCV. If I understand correctly provided examples, code below:
should produce result, which I type-hint in my code as:
of course actual result uses lists instead of tuples for bounding box, but this allows slightly better type-checking, since you cannot type-hint list with constant length, but this doesn't really matter.
What does matter, is that it should be possible to use this output directly, to draw result on image using OpenCV:
However on some rare occasions, snippet of code above would throw on
cv2.drawContours
, with error message:cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\drawing.cpp:2504: error: (-215:Assertion failed) npoints > 0 in function 'cv::drawContours'
On closer inspection in debugger, it seems that when error occurs,
reader.readtext(...)
returns result in which bounding box points are of typefloat
, and not the expectedint
(int
points are being returned +99% of times):Of course this can be fixed in user code, which in snipped above would be:
however I feel that either examples in this repository in readme.md and on site https://www.jaided.ai/easyocr/tutorial/ are misleading, showing that only
int
numbers can be expected in bounding box component of output, or there is some rare bug which results in non-integer output.The text was updated successfully, but these errors were encountered: