AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

How to locate specific rect on image

The forum is to discuss topics related to different areas of image processing and computer vision.

How to locate specific rect on image

Postby tevosouza » Sat Sep 07, 2019 2:25 pm

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.

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


Thanks!!
tevosouza
 
Posts: 4
Joined: Fri Sep 06, 2019 7:30 pm

Re: How to locate specific rect on image

Postby andrew.kirillov » Tue Sep 10, 2019 8:44 pm

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?
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: How to locate specific rect on image

Postby tevosouza » Wed Sep 18, 2019 9:46 pm

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!
tevosouza
 
Posts: 4
Joined: Fri Sep 06, 2019 7:30 pm

Re: How to locate specific rect on image

Postby andrew.kirillov » Thu Sep 19, 2019 7:04 am

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.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: How to locate specific rect on image

Postby tevosouza » Fri Sep 20, 2019 8:36 pm

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 (2.1 KiB) Viewed 8858 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!
tevosouza
 
Posts: 4
Joined: Fri Sep 06, 2019 7:30 pm

Re: How to locate specific rect on image

Postby tevosouza » Sat Sep 21, 2019 3:22 am

Hit and Miss filter done the job!
Thanks a lot for help!

Result:
nfresult_hm.png (2.7 KiB) Viewed 8853 times
tevosouza
 
Posts: 4
Joined: Fri Sep 06, 2019 7:30 pm




Return to Image Processing and Computer Vision