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
{{ message }}
Repository navigation
Tools that touch or cross the sheet edge may be traced incorrectly #212
Outcome
Two related failures, both when a tool is not neatly inside the sheet. My 300mm plier overhangs a Letter sheet.
A tool overhanging the sheet edge may be cut off with a straight line. The mask ends in a flat horizontal edge at the paper boundary while the rest of the outline traces perfectly. On my photo, 187px of the plier head sat outside the crop. Only the overhanging end was affected, which is what makes it look like a rendering glitch rather than a crop.
A tool spanning the paper divides the visible white into two regions; the crop keeps the larger and discards the tool with the other. On my photo it returned a strip covering 22% of the sheet, and the tracer then returned whatever texture remained — on graph paper, the printed ruling.
I had this issue trying to create a feature that auto-selected the corners for me when I was having other issues with this grid background.
Where
Both come from AITracer._detect_paper_rect, which crops to the paper before segmentation:
largest = max(contours, key=cv2.contourArea)
x, y, bw, bh = cv2.boundingRect(largest)
largest alone causes (2). Cropping to the paper's bounds causes (1).
This looks like a contradiction: apply_perspective_correction already goes out of its way to keep the overhang:
"includes the full visible area beyond the paper so oversized tools are captured"
The warp preserves it, and then the crop throws it away.
Suggested direction
For (2), bound every substantial bright region rather than only the largest — the paper is their union and the tool sits inside it. For (1), let the crop reach over mid-tone or colored mass that touches it; near-black is backdrop and very bright is sheet, so neither can drag the crop outwards.
Reproduction
I did some regression tests for both that fail against main (13166cd) and pass with the fix.
Activity
jasonmadigan commentedon Sep 17, 2026
Yep, looks like a bug. Reproduced with your photo, thanks. Will fix.
fix: keep overhanging tools, detect paper on dark backgrounds, mask e…