public interface IRecognitionBlock
This interface represents a block.
Block is a rectangular region that may contain text, picture or any other data. OCR Engine will recognize whole image and will try to find text blocks by itself, if blocks are not specified by user.
OcrEngine ocr = new OcrEngine(); ocr.Image = ImageStream.fromFile(@"image.tiff"); ocr.getLanguageContainer().addLanguage(LanguageFactory.load("Portuguese-RSC-HS-PB-ResourcesAllCharsNet.zip")); // Resource file name IRecognitionBlock pictureBlock = RecognitionBlock.createPictureBlock(0, 0, 100, 200); ocr.getConfig().addRecognitionBlock(pictureBlock); IRecognitionBlock textBlock = RecognitionBlock.createTextBlock(110, 210, 100, 100); ocr.getConfig().addRecognitionBlock(textBlock); if (ocr.process()) { if (textBlock.getRecognitionData() instanceof IRecognizedTextPartInfo) System.out.println(((IRecognizedTextPartInfo)textBlock.isRecognitionData()).getText()); }
Modifier and Type | Method and Description |
---|---|
UUID |
getBlockId()
Sets when the block is created.
|
IRecognizedPartInfo |
getRecognitionData()
Gets the recognition data.
|
Rectangle |
getRectangle()
Returns the rectangle that defines recognition block inside specified image
|
boolean |
getToRecognize()
Shows if block needs to be processed by OCR Engine
|
char[] |
getWhitelist()
Gets a white list of characters for the recognition block.
|
void |
setWhitelist(char[] value)
Sets a white list of characters for the recognition block.
|
UUID getBlockId()
IRecognizedPartInfo getRecognitionData()
Rectangle getRectangle()
boolean getToRecognize()
char[] getWhitelist()
OcrEngine ocr = new OcrEngine(); IRecognitionBlock block = RecognitionBlock.createTextBlock(x, y, width, height); block.setWhitelist(new char[] {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'}); ocr.getConfig().addRecognitionBlock(block); ocr.getConfig().setDetectTextRegions(false); ocr.setImage(ImageStream.fromFile("numbers.png")); ocr.process();
void setWhitelist(char[] value)
Copyright © 2017. All Rights Reserved.