Hi Monks, I was trying to randomly capture the picture through HD Camera and convert it to the Tiff file. So that it can be used for OCR. In this Situation, I tried to OCR an image which has no image content, perl interpreter crashes @$miDoc->{Images}->Item(0)->{Layout}{Text} Please find the code I have tried:
sub ApplyOCR{ my $TiffImageLocation = $_[0]; my $LogFilePath = $_[1]; if (-f $LogFilePath){ unlink $LogFilePath; } Win32::OLE::Const->Load("Microsoft Office Document Imaging 12\.0 T +ype Library") or die "Cannot use the Office 2007 OCR API"; my $miDoc = Win32::OLE->new('MODI.Document') or die "Cannot creat +e a MODI object"; $miDoc->Create("$TiffImageLocation"); $miDoc->OCR(9,1,1); my $OCRResult = $miDoc->{Images}->Item(0)->{Layout}{Text}; open (LOG, ">>$LogFilePath") or die $!; if ($Image){ print LOG "Image Name : $Image\n"; print LOG "==========\n\n"; } print LOG "OCRResult : \n"; print LOG "$OCRResult\n\n"; close LOG; }
Please tell me how can I find that the object $miDoc has not text content. So that I can avoid this crash.


In reply to Perl intepreter crash when tyring to get the text from OCRed output by priyaviswam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.