Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect roi of numbers

How can i detect roi of big 8 digit number in attached image?

 

Thanks in Advance

0 Kudos
Message 1 of 11
(7,495 Views)

Usually you would use some sort of fiducial in the original image.  If you post the original, I might have some ideas.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 11
(7,472 Views)

Can you please clarify your question because I'm not exactly sure what you would like to do? Is your question about how to create an ROI in the Vision Development Module? Do you want to read the text and digitize it? If so, you should look at the Optical Character Recognition examples with the NI Vision Development Module. 

 

Good luck,

Jeremy P.

Applications Engineer
National Instruments
0 Kudos
Message 3 of 11
(7,466 Views)

Here is the original, maybe not same because it is frame taken from video.

0 Kudos
Message 4 of 11
(7,445 Views)

Thanks for replyes. I have a video with moving train and  I need to detect numbers on each coach. First I decide to detect possible ROI where maybe is the number, then try to read it (using NI Vision), because numbers often are bad quality and not same font. Attached frame for example.

Download All
0 Kudos
Message 5 of 11
(7,444 Views)

This project is going to be more difficult than it seems.  Figuring out all the possible fonts, all the possible sizes, plus poor quality will make it almost impossible.  I would consider researching license plate readers, because it is the same sort of application.

 

To locate the characters, I would probably use thresholding with background correction to try to get all of the characters.  I would use a few iterations of dilate to fill in the gaps on the numbers with breaks in them.  I would then eliminate any objects less than a minimum height and width to get rid of all the small characters.  All that should be left is the large characters, possibly blended together.  Combine the bounding rectangles for objects that meet the criteria (roughly same row withing 1/4 character, reasonable spacing, etc.) to get one rectangle with the entire number in it.

 

The hard part will be reading the numbers.  Unless you can train a font for every possible situation, OCR won't be terribly helpful.  You might want to research handwriting recognition to come up with ways to read any number without having an example font.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 6 of 11
(7,417 Views)

With the NI Vision Development Module and LabVIEW or with the NI Vision Builder for Automated Inspection, you can read letters, numbers and other symbols using the Optical Character Recognition functions.

 

I would like to clarify how these functions work. You can use these functions to create a library of characters that the software will search for in the image. You would need to extract these letters, numbers and symbols from sample images of the boxcars. When you use NI's vision software to create a character set, it will open a wizard that will help you to select each character, one-by-one, from the images. Then, in a field on the wizard, you will type the letter that corresponds to the image of the letter that you extracted. In this way, you will train the software to recognize each letter.

 

You will probably need to do this for every symbol in every font that you expect to see. Also, if the images are blurry or if the letters and symbols are deformed in any way then the software will have a hard time reading it.

 

Jeremy P.

Applications Engineer
National Instruments
0 Kudos
Message 7 of 11
(7,413 Views)

Thanks for advice, I'll try this idea.

0 Kudos
Message 8 of 11
(7,396 Views)

Hi,

 

the first thing you need to do, is to use a local threshold.

 

I used a local threshold with background correction with a window of 350x350 px

That turns your image into something so much nicer:

01.PNG

 

As a second step, I would NOT use OCR. OCR is fine if you are looking at known text in one font, for this kind of problem with obscured letters, letters that sometimes have spaces inside (look at the 8.. it's 2 particles) etc. I'd prefer using Pattern Matching.

 

That means, you are going to teach the Pattern Matching all the letters, like 8 in this example,

8_pattern.png

and then you get results. Note that in this image I used actually a different 8 from another image..

 

02.PNG

 

It works pretty welll, even if you do not finetune the parameters much. Now, you need to teach all the letters to Pattern Matching, maybe even with some scaling.

Pattern Matching has to be set up in a way that it allows you to find multiple instances of the letters, allow for some tolerance (I'd search aggressively, but then again, I don't know your data), and get results.

 

That would result in a list of many coordinates with letters and match score.

 

Then I'd eliminiate "multiple" finds (coordinates that are very close to each other) by sorting them according to their Match Score. (For example, that 8 would probably be found as a 0 in another font, but have a better score with the 8..)

 

Finally, I'd put the data together, sort it according to the coordinates and get the text I want to read.

 

If I had a video stream, I'd probably read multiple images of the same train, and use that as another information to improve my data quality.

 

This is a rough outline. The algorithm is going to be slow, but parallelizable if necessary, and probably quite robust.

 

 

0 Kudos
Message 9 of 11
(7,380 Views)

A few month ago I used Tesseract OCR with a LabVIEW app because it gave much better results than NI Vision's OCR.

 

The use case was a bit similar to yours, poor image quality, lots of different font and sizes.

 

Good luck


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 10 of 11
(7,363 Views)