-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle contour with zero area exceptions #11909
Conversation
In case any two coordinates of a contour are same, it will make a triangular region instead of rectangular one. Thus, when creating polygon from that contour, the area of the box (and thus distance) will be zero, resulting in an empty box. This results the following error during minimum area calculation: ``` bounding_box = cv2.minAreaRect(contour) cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\convhull.cpp:143: error: (-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) in function 'cv::convexHull' ```
Thanks for your contribution! |
Would it be possible to provide some images that reproduce this problem? |
@GreatV, I have edited the description with the images and the contour output for this specific case. |
@GreatV CI passed after rerun. |
Hi @zovelsanj, this fix does not seem to work well. paddleocr --image_dir=322704193-d4be89fc-13e4-448d-a614-20cb8a037ad5.png --lang=japan --det_box_type=poly
|
Hi @GreatV, thanks for pointing out. I tested it and I think the error is due to |
The |
ok, it seems so. This fix is still mergeable, isn't it? |
Hi @zovelsanj, would you be willing to try to fix these issues to make |
paddleocr --image_dir=322704193-d4be89fc-13e4-448d-a614-20cb8a037ad5.png --lang=japan --det_box_type=poly --det_db_unclip_ratio=2.5
|
Thanks @GreatV. Last time, I checked Can you verify this from your side? |
Hi @GreatV, minimum area polygons may fix this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still can't reproduce it successfully, so I may need to wait until you submit your next PR that addresses the other issues before I can check this again.
Did you check with higher values of |
Hi @zovelsanj. This is weird, no matter how I set it up it doesn't work in this mode. Would you be able to provide your script for running it? |
Hi @GreatV, its indeed weird that it doesn't work on your part. Here is how i am using:
Nothing complicated, just straight forward. Let me know if you are able to solve the issue on your side. |
still not work
|
@zovelsanj, thank you for your contribution. |
In case the contour is very small (like a single pixel contour), it will make a line instead of polygonal detection region. Thus, when creating polygon from that contour, the area of the polygon (and thus distance) will be zero, resulting in an empty box. This results the following error during minimum area calculation:
This error was found specifically with
det_box_type='poly'
, but it may also occur in the case ofdet_box_type='quad'
. Here is the figure to replicate the error.For privacy reasons, I have to erase few areas in this image. The erroneous detection region coordinates are:
[[909 353], [908 353], [907 352], [906 352], [905 353], [901 353], [901 354], [902 353], [907 353], [908 354]]
The contour made by these coordinates is shown below (by red line).