Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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

Replies are listed 'Best First'.
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?
[Corion]: marto: Ow! You got hit by the storm that is bringing warm weather to me ...
[1nickt]: marto Good to hear that was the worst of it for you...
[marto]: 1nickt the worst I'm aware of at the moment :P
LanX .♩..♬ ... Another one bites the Sahara dust ...
marto wonders what fresh hell the firefox update has brought, apart from maxing out CPUs
1nickt was looking into Firefox Extended Support releases yesterday. You don't have to go with the updates!
[erix]: wonderfully red sun here
[LanX]: FF has become a source of instability :(

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-10-17 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (230 votes). Check out past polls.

    Notices?