bauerj / paperless_app

An Android/iOS app for Paperless
https://play.google.com/store/apps/details?id=eu.bauerj.paperless_app
GNU General Public License v3.0
525 stars 46 forks source link

"Triangle bug" when cropping images #32

Open TheLastProject opened 3 years ago

TheLastProject commented 3 years ago

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

bauerj commented 3 years ago

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.

TheLastProject commented 3 years ago

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 commented 3 years ago

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?

bauerj commented 3 years ago

Thanks for confirming, that's great to hear!

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

bauerj commented 3 years ago

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.

TheLastProject commented 3 years ago

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...

bauerj commented 3 years ago

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

mvdkleijn commented 3 years ago

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.