Page 1 of 1

How to locate specific rect on image

PostPosted: Sat Sep 07, 2019 2:25 pm
by tevosouza
Hi!
Can anyone help me, i'm trying to locate a specific rect on the image (attached), i need to identify the rect that contains the number (NF on my country is Invoice) - i put the red line to show the area that i need to get.

Screenshot from 2019-09-07 11-16-29.png
Invoice
Screenshot from 2019-09-07 11-16-29.png (220.67 KiB) Viewed 519 times


Thanks!!

Re: How to locate specific rect on image

PostPosted: Tue Sep 10, 2019 8:44 pm
by andrew.kirillov
Hello,

Are you looking for rectangle, which contains NF-e and can be anywhere in the image? Or you just need to locate to right most one?

Re: How to locate specific rect on image

PostPosted: Wed Sep 18, 2019 9:46 pm
by tevosouza
andrew.kirillov wrote:Hello,

Are you looking for rectangle, which contains NF-e and can be anywhere in the image? Or you just need to locate to right most one?


Hi!

The rect containing the NF-e is always on the right side of the image.

Thx for your reply!

Re: How to locate specific rect on image

PostPosted: Thu Sep 19, 2019 7:04 am
by andrew.kirillov
Hello,

Try thresholding then with Blob Counter on top. If the black border is thinck enough and is not broken, then innter white area should be possible to find as a single blob.

Re: How to locate specific rect on image

PostPosted: Fri Sep 20, 2019 8:36 pm
by tevosouza
andrew.kirillov wrote:Hello,

Try thresholding then with Blob Counter on top. If the black border is thinck enough and is not broken, then innter white area should be possible to find as a single blob.


I've tried it and got detects about 60% - 70% (good results, but not enough yet because i need to scan about 80.000 documents / monthly).
I applied gamma correction (0.5), threshold (about 130 - 135) and color filtering (range in 211 - 255, white) and (range 0-210, black) to "try' to improve results, but it doesn't work well for me.

I've attached my result as follows:
nfe_results.png
nfe_results.png (2.1 KiB) Viewed 438 times


After "detection" i will run an OCR to get the numbers (Nº) and serial number (ŚERIE) of the image, i'm using blobs to detect rect on thresholded image, but the crop i'm applying on original image with the detected rect to run OCR, when rectangle is detected OCR run like a charm, but when detection fails i get no result ;/

Is there any way to "reforce" the lines on image to improve the detection or another way?

Thanks a lot for the help!

Re: How to locate specific rect on image

PostPosted: Sat Sep 21, 2019 3:22 am
by tevosouza
Hit and Miss filter done the job!
Thanks a lot for help! ;)

Result:
nfresult_hm.png
nfresult_hm.png (2.7 KiB) Viewed 433 times