Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
laziness, impatience, and hubris
 
PerlMonks  

Re^4: Why the Create method keep failing using Office 2007 OCR API?

by ZJ.Mike.2009 (Scribe)
on Mar 02, 2010 at 04:15 UTC ( #826067=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Why the Create method keep failing using Office 2007 OCR API?
in thread Why the Create method keep failing using Office 2007 OCR API?

@Anonymous Monk, thanks a lot for the guidance. I tested the modified code with a MDI file that already has OCR information like so:

$miDoc->Create('OCR-test-result.mdi'); my $OCRresult = $miDoc->{Images}->Item(0)->{Layout}{Text}; print $OCRresult;
It outputs the expected result. But if I retain the OCR method like the original code did:
$miDoc->Create('OCR-test.tif'); $miDoc->OCR(LangId =>'miLANG_ENGLISH'); my $OCRresult = $miDoc->{Images}->Item(0)->{Layout}{Text}; print $OCRresult;
Perl throws me the same error message: Use of uninitialized value $OCRresult in print

So now it looks like there's also something wrong with this line:

$miDoc->OCR(LangId =>'miLANG_ENGLISH');
What diagnostic method can I use to solve the problem. The following code gives me nothing:
eval {$miDoc->OCR(LangId =>'miLANG_ENGLISH')}; warn $@ if $@;
Thanks again :)


Comment on Re^4: Why the Create method keep failing using Office 2007 OCR API?
Select or Download Code
Re^5: Why the Create method keep failing using Office 2007 OCR API?
by Anonymous Monk on Mar 02, 2010 at 04:31 UTC
    $miDoc->{Images}->Item(0)->{Layout}{Text};
    is four operations, and each and every one can fail
    my $images = $miDoc->{Images} || die $^E; my $first = $images->Item(0) || die $^E; my $layout = $first->{Layout} || die $^E; my $text = $layout->{Text} || die $^E;
      @Anonymous Monk, thanks again. If I were to load an MDI file that already has the OCRed result information, the script would output the OCRed text. Otherwise, it dies at the last step. For the above four operations, it dies at my $text line.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-04-21 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls