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
File "...lib/python3.11/site-packages/surya/input/processing.py", line 43, in slice_polys_from_image
lines.append(slice_and_pad_poly(image_array, poly))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...lib/python3.11/site-packages/surya/input/processing.py", line 58, in slice_and_pad_poly
cv2.fillPoly(mask, [np.int32(coordinates)], 1)
cv2.error: OpenCV(4.11.0) :-1: error: (-5:Bad argument) in function 'fillPoly'
> Overload resolution failed:
> - Layout of the output array img is incompatible with cv::Mat
> - Expected Ptr<cv::UMat> for argument 'img'
I attempted to debug the parameters passed to fillPoly, and the relevant context is as follows:
# Pad the area outside the polygon with the pad value
mask = np.zeros(cropped_polygon.shape[:2], dtype=np.uint8)
print(coordinates)
print(cropped_polygon.shape[:2])
cv2.fillPoly(mask, [np.int32(coordinates)], 1)
It appears that the height of the mask is 0, which caused the fillPoly function to throw an error.
To address this, I modified the code as follows:
# Pad the area outside the polygon with the pad value
mask_shape = cropped_polygon.shape[:2]
# If mask shape is 0, it means the polygon is outside the image, so we return the full image
if(mask_shape[0] == 0 or mask_shape[1] == 0):
return Image.fromarray(image_array)
mask = np.zeros(cropped_polygon.shape[:2], dtype=np.uint8)
This modification avoids the error while returning a basically correct result. However, since I am not very familiar with the overall structure of marker, I am unsure whether this fix is reasonable. If the fix is acceptable, could it be merged into the upstream? If needed, I can also create a pull request.
Unfortunately, I am unable to upload the image that triggers the error because I spent dozens of minutes trying to redact private information from it. However, once the private information is removed, the exception no longer occurs. If the image is absolutely necessary, I may need to obtain authorization and then consider sending it via email.
Thank you for your understanding and support!
The text was updated successfully, but these errors were encountered:
First of all, I would like to express my gratitude for the two outstanding open-source projects,
marker
andsurya_ocr
.When I process a specific single image, for example, by running the following command:
I encounter the following error:
I attempted to debug the parameters passed to
fillPoly
, and the relevant context is as follows:The output is:
It appears that the height of the
mask
is 0, which caused thefillPoly
function to throw an error.To address this, I modified the code as follows:
This modification avoids the error while returning a basically correct result. However, since I am not very familiar with the overall structure of
marker
, I am unsure whether this fix is reasonable. If the fix is acceptable, could it be merged into the upstream? If needed, I can also create a pull request.Unfortunately, I am unable to upload the image that triggers the error because I spent dozens of minutes trying to redact private information from it. However, once the private information is removed, the exception no longer occurs. If the image is absolutely necessary, I may need to obtain authorization and then consider sending it via email.
Thank you for your understanding and support!
The text was updated successfully, but these errors were encountered: