OpenCV Android - Detect partial rectangle/paper

Hi everyone! I’m new to OpenCV and I’m trying to implement the library on Android, here is my use case:

I need to use the camera to detect a receipt in real time, so far I’ve manage to detect it if the full receip is shown (using rectangle detection) but if I focus my camera only to one part of the receipt it wont detect it as a rectangle and my implemantation fails.

This is my current implementation working and the fail case

I’ll really appreciate if someone can help me solving this.

Best regards,

Bryan

what are you actually interested to retrieve from that receipe ?

though it’s somewhat obvious to look for a rectangular outline, just saying, maybe you do not need the whole rectangle anyway

also, there are insteresting alternative ways to retrieve text from an image, using dnns

The thing is that I need to crop the picture to only the receipt, so I get the points and crop the photo after that. Then I send the photo to an endpoint that extracts the info. So I just need to be able to detect and crop the receipe from the rest

I guess you could cheat and add a rectangle around the image before detection - then you’d always have a full rectangle