FixedWire Posted February 5, 2019 Report Share Posted February 5, 2019 It's seems simple enough to read a number that can be 1 or 2 digits and randomly rotated. I've tried to train the OCR but am not getting the expected accuracy. One neat bit of code was https://forums.ni.com/t5/Example-Programs/Programmatically-Generate-an-Optical-Character-Recognition-OCR/ta-p/3491108 Any suggestions? Here's an example: Quote Link to comment
caleyjag Posted February 5, 2019 Report Share Posted February 5, 2019 (edited) Do your images always look like this? I'd experiment with using the white circles to center your frame of reference. Once you have your coordinates set, I'd do a quick binary threshold on the central area where the numbers are, and use some binary morphology to fill the cavities inside your digits. I'd first try the IMAQ Fill Holes.vi (I think it's called something like that). Alternatively, you can try dilate/erode combination, which may work better here in the even the numbers don't fully enclose the cavities every time. Once you have done that the OCR might work better. There are quite a lot of other tools you can play with to sharpen up your image. I'm not sure how well the OCR algorithms perform if the number is printed at an arbitrary angle. I've never tried that, so I'm interested to see. Alternatively, if your digits are always the same you could try making 10 templates (0-9) and using the IMAQ object/pattern matching VIs which are rotationally invariant. Would be a bit more work for you on the back end to figure out the ordering of the digits though Edited February 5, 2019 by caleyjag Quote Link to comment
FixedWire Posted February 27, 2019 Author Report Share Posted February 27, 2019 Thanks caleyjag. I got the code to work nicely after using your suggestions. It all boiled down to really cleaning up the image and training. The image needed to be rotated until the confidence level was met. i.e. the OCR was trained in a consistent way. Subtleties such a slight twist or how light/dark the value was required manual intervention with a lot of samples. The final result was >98% accuracy across 6.5k images. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.