Commit 925e2ed
Fix crop_margin crash with extreme aspect ratio images (#17686)
Add bounds checking to crop_margin in GoTImgDecode, UniMERNetImgDecode,
and UniMERNetResize to handle edge cases:
- Return original image when cv2.findNonZero returns None (no text found)
- Return original image when bounding rect has zero width or height
- Return original image when cropped result would have aspect ratio > 200,
which causes ValueError in downstream image processing
Fixes #17354
Co-authored-by: Lin Manhui <mhlin425@whu.edu.cn>1 parent b6a561d commit 925e2ed
1 file changed
+21
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
| 498 | + | |
| 499 | + | |
498 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
499 | 506 | | |
500 | 507 | | |
501 | 508 | | |
| |||
595 | 602 | | |
596 | 603 | | |
597 | 604 | | |
| 605 | + | |
| 606 | + | |
598 | 607 | | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
599 | 613 | | |
600 | 614 | | |
601 | 615 | | |
| |||
720 | 734 | | |
721 | 735 | | |
722 | 736 | | |
| 737 | + | |
| 738 | + | |
723 | 739 | | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
724 | 745 | | |
725 | 746 | | |
726 | 747 | | |
| |||
0 commit comments