04-10-2011 10:26 PM
The code:
'NIOCR1.ReadText2 CWIMAQViewer1.Image, readString, CWIMAQViewer1.Regions, charReport'
in the 'OCR First Example' seams to not work as advertised. I attached a picture of the application where I draw an ROI as instructed and 'ReadText2' function seams to just ignore the region and trys to read everything in the image. I have an application I'm trying to develop that reads multiple lines of text on a label using several ROIs to separate them and it doesn’t even work at all because of this. It does seam to work in the Vision Assist program so I attached an example so you can see what I'd like it to do.
Please help...
04-12-2011 10:43 AM
Hi Gearsoft,
I ran the same example (OCR First Example) and did not see the same behavior. It seemed to only report the letter or letters in the ROI that I selected.
What version of vision do you have? I am running Vision Development Module 2010. I'm not sure if it has changed between versions, but it is possible. If you post your example I can run it and see if I get the same result.
04-12-2011 11:59 PM
Hi Justin,
Here's the example I'm using. It's straight out of the Vision Development Module 2010. I'm running it in Windows XP 32 bit with VB6 SP6. Also I've tried it on several other XP and Windows 7 computers with the same results. I really need this feature to work in my project or I may have to do some masking or some other 'work-around' to extract the text.
Thanks,
John
04-14-2011 11:29 AM
Hi Gearsoft,
I actually do see the same behavior. The example that I said was working before was a C example that I ran in CVI. I found this example under Documents\National Instruments\CVI\samples\Vision\2. Functions\OCR.
I apologize for not paying closer attention to the original post. I actually do see the same behavior as you described earlier. I am currently looking at these examples and trying to figure out what is wrong with the VB example.
04-14-2011 05:33 PM
Justin,
I'm glad to see it's not just me. I hope you do find the answer to this. My thought is that there's an issue with the vb ocx wrapper file. If that's the case can you get me the direct declarations for the niocr.dll file? ie: 'Declare Sub ReadText2 Lib "niocr.dll" (ByRef Image as Object, ByVal readString as String, ByRef Regions as Object, ByRef charReport as Object)' (something like that) and the other functions that pertain to niocr.dll.
Here's all of the ocr related functions from the C header file but I need them in vb, if there's no other work-around, and I don't know how to do the convertion:
//============================================================================// OCR functions//============================================================================IMAQ_FUNC CharSet* __stdcall imaqCreateCharSet(void);IMAQ_FUNC int __stdcall imaqDeleteChar(CharSet* set, int index);IMAQ_FUNC int __stdcall imaqGetCharCount(const CharSet* set);IMAQ_FUNC CharInfo2* __stdcall imaqGetCharInfo2(const CharSet* set, int index);IMAQ_FUNC int __stdcall imaqReadOCRFile(const char* fileName, CharSet* set, String255 setDescription, ReadTextOptions* readOptions, OCRProcessingOptions* processingOptions, OCRSpacingOptions* spacingOptions);IMAQ_FUNC ReadTextReport2* __stdcall imaqReadText2(const Image* image, const CharSet* set, const ROI* roi, const ReadTextOptions* readOptions, const OCRProcessingOptions* processingOptions, const OCRSpacingOptions* spacingOptions);IMAQ_FUNC int __stdcall imaqRenameChar(CharSet* set, int index, const char* newCharValue);IMAQ_FUNC int __stdcall imaqSetReferenceChar(const CharSet* set, int index, int isReferenceChar);IMAQ_FUNC int __stdcall imaqTrainChars(const Image* image, CharSet* set, int index, const char* charValue, const ROI* roi, const OCRProcessingOptions* processingOptions, const OCRSpacingOptions* spacingOptions);IMAQ_FUNC int* __stdcall imaqVerifyPatterns(const Image* image, const CharSet* set, const String255* expectedPatterns, int patternCount, const ROI* roi, int* numScores);IMAQ_FUNC int* __stdcall imaqVerifyText(const Image* image, const CharSet* set, const char* expectedString, const ROI* roi, int* numScores);IMAQ_FUNC int __stdcall imaqWriteOCRFile(const char* fileName, const CharSet* set, const char* setDescription, const ReadTextOptions* readOptions, const OCRProcessingOptions* processingOptions, const OCRSpacingOptions* spacingOptions);
I'm probably jumping the gun here so I'll wait to see what you find.
Thanks,
John
04-18-2011 12:46 AM
Hi Justin,
I couldn't wait for your response so I came up with this workaround.
Here's a snipit of the code and I attached the modified vb example:
12-07-2012 03:28 PM
I am having this same problem and National Instruments has not been very helpful so far.
I need to specify a rotated ROI so the extract work arround will not work for me.
I have been trying to get my application I wrote in 2007 to run with the new versions, but it appears more is broke than fixed over the years.
12-10-2012 03:41 PM
When you talk about the 2007 versions and the new versions are you talking about the Vision drivers or Visual Basic? Also, as a note, this is an older thread. Newer threads get more attention from users. It would be a good idea to create a new thread on your question.