priyaviswam has asked for the wisdom of the Perl Monks concerning the following question:
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:
Please tell me how can I find that the object $miDoc has not text content. So that I can avoid this crash.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; }
|
---|
Back to
Seekers of Perl Wisdom