03-26-2008 04:08 AM
03-27-2008 02:38 PM
Hello Mar-Q,
Thank you for contacting National Instruments! I am assuming that you have the Vision Development Module which includes the appropriate Vision VIs. I believe your best bet is to stick with pattern matching. One way to address the distortion caused by taking the image from an angle is calibration. This is intended for a fixed camera setup so it is not suited for your application. The other option is to use pattern matching. I suggest you first create a template of the label straight on. Set the Minimum Score input for the Match Pattern VI to allow for the inconsistencies in the image. As long as you can set the Minimum Score low enough to recognize the label most of the time in addition to not throw false positives this should work for you. Please realize this will take many trials to determine if your minimum score is working.
If this does not work, you may have to get a little more sophisticated with your programming. You could make several templates and loop through them to check for a match. Say you take three templates to start with: a template from the right hand, left hand and straight on perspectives. Then run your pattern match through all three and to check for the presence of the label. You will need to adjust the minimum score on this pattern match, too, and there will need to be several trials to get templates just right.
Take a look at the example called Pattern Matching Example.vi. This takes an 8-bit grayscale image input.
As for setting the ROI for OCR, you can do this several ways programmatically. This issue I see with your application is that the ROI is not always in the same place. Although, the ROI does not need to be a perfect outline of the label. If you could narrow the ROI down to an area, say the center of the image, even the top half of the image this would help the algorithm when looking for characters. As far as implementation goes, you can use any of the IMAQ Convert Shape to ROI. I would suggest using IMAQ Convert Rectangle to ROI. This will allow you to programmatically set the points of your region and convert it in to ROI data for the rest of the OCR process.
Does this help?
03-28-2008 04:39 PM