Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Perl intepreter crash when tyring to get the text from OCRed output

by sundialsvc4 (Abbot)
on Nov 17, 2011 at 13:40 UTC ( #938621=note: print w/ replies, xml ) Need Help??


in reply to Perl intepreter crash when tyring to get the text from OCRed output

Ummm... it doesn’t really mean anything, not to a programmer anyway, merely to say that “it crashed.”   Give us specific details:   exactly what you saw, after doing what, and under exactly what conditions.


Comment on Re: Perl intepreter crash when tyring to get the text from OCRed output
Re^2: Perl intepreter crash when tyring to get the text from OCRed output
by Anonymous Monk on Jan 11, 2012 at 06:06 UTC

    As refered to the issue posted by me, Please Check the latest code

    sub ApplyOCR{ my $TiffImageLocation = $_[0]; my $OCRResult; print "InitOnce : $InitOnce\n"; if ($InitOnce == 0) { $InitOnce = 1; #### To make it one time initialization $miDoc = Win32::OLE->new('MODI.Document') or die "Cannot crea +te a MODI object"; print "miDoc : $miDoc\n"; } #### Creat the new document $miDoc->Create("$TiffImageLocation"); $miDoc->OCR(9,1,1); $miDoc->Save(); # print "Save object\n"; # print Dumper ($miDoc); # print "\n"; try{ my $ImageDoc = $miDoc->{Images}; if (defined $ImageDoc){ $OCRResult = $miDoc->{Images}->Item(0)->{Layout}{Text}; #### Close the opened document $miDoc->Close(); return $OCRResult; }else{ if ($DebugMsg == 1){ print "OCR cannot be done on this image in $TiffImageL +ocation\n"; #comment to debug- this is the message and } return 1; } }catch{ my $err = shift; warn "Some other kind of error in try: $err\n"; throw $err; if ($DebugMsg == 1){ print "OCR cannot be done on this image in $TiffImageLocat +ion\n"; #comment to debug- this is the message and } return 1; } }

    For the tiff image which has not text content in it, then the code breaks at line 25. Since it has no text content the $miDoc don't have the property item(0). Please help me how to capture this error/exception.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://938621]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2015-07-05 05:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls