paperless_app icon indicating copy to clipboard operation
paperless_app copied to clipboard

"Triangle bug" when cropping images

Open TheLastProject opened this issue 4 years ago • 8 comments

Often it creates absurd shapes like this triangle. Having only 3 points I can't properly crop... anything. It makes it very hard to actually use this app at all.

image

TheLastProject avatar Jan 04 '21 19:01 TheLastProject

Hello Sylvia,

I'm sorry that this issue makes it hard for you to use the app.

Generally, it works best when the document is evenly lighted and the edges are clearly visible. I know that other solutions perform better under less than ideal circumstances. However, we are no computer vision experts and do not have a large development team.

The "triangle bug" is frustrating but frankly I don't really understand the upstream code that's causing this.

The latest release (0.0.10) had some improvements with regards to the scanner. Can you confirm you are using that version?

Another thing you could try is to use a third-party scanning app and the share feature to add it to Paperless.

bauerj avatar Jan 04 '21 21:01 bauerj

Ah, sorry, I should've checked the version I'm using of course. I'm still on 0.0.9 it seems, which is the latest on F-Droid currently. I'll try 0.0.10 soon and see if that works better. I'll report back tomorrow most likely

TheLastProject avatar Jan 04 '21 21:01 TheLastProject

I can't quite pinpoint why but 0.0.10 does seem a lot more reliable although I can still see it generate triangles I haven't had it actually create one when I pressed the camera button. So I suppose this count be closed, unless you want me to keep it open until there are no triangles generated at all?

TheLastProject avatar Jan 05 '21 19:01 TheLastProject

Thanks for confirming, that's great to hear!

I guess we can leave this open since triangular documents are not really common.

bauerj avatar Jan 05 '21 19:01 bauerj

So, I just looked into it and the detection code actually checks whether the shape is a quadrilateral:

https://github.com/bauerj/edge_detection/blob/9a9e34d221c6e4f91bf4d2e5b525383b5988a0ba/android/src/main/kotlin/com/sample/edgedetection/processor/PaperProcessor.kt#L112

So... yeah, I'm still clueless as to how this happens. I could even make it detect a line but it took a lot of tries.

bauerj avatar Jan 06 '21 17:01 bauerj

Hmm, I wonder if there are 4 points but 1 or 2 of those points happens to be at the exact same place as another point. Hmm...

TheLastProject avatar Jan 06 '21 18:01 TheLastProject

That might be the case but when moving those points I don't see anything hidden behind.

bauerj avatar Jan 06 '21 18:01 bauerj

Some tips for scanning:

Make sure to have enough light, preferably from your phone or a light on the side so you don't cast shadows on the document.

Using a black garbage bag or something as a background to white document helps a lot. In other words, make sure to have enough contrast.

@TheLastProject I see you're Dutch (image is of the tax office...) I use one of those KOMO garbage bags, half unfolded. Works fine with a small desk spotlight on the side.

mvdkleijn avatar Jan 11 '21 13:01 mvdkleijn