3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/asposeocrjava/OCR/extracttextfrompartofimage.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
ocr_engine = Rjb::import('com.aspose.ocr.OcrEngine').new
ocr_engine.clearNotifies()
ocr_engine.getConfig().clearRecognitionBlocks()
ocr_engine.getConfig().addRecognitionBlock(Rjb::import('com.aspose.ocr.RecognitionBlock').createTextBlock(52, 48, 67, 74))
ocr_engine.getConfig().addRecognitionBlock(Rjb::import('com.aspose.ocr.RecognitionBlock').createTextBlock(100, 46, 38, 46))
ocr_engine.getConfig().setDetectTextRegions(false)
ocr_engine.setImage(Rjb::import('com.aspose.ocr.ImageStream').fromFile(data_dir + 'ocr.png'))
if ocr_engine.process()
text = ocr_engine.getText().getPartsInfo()
i = 0
while i < text.length
info = text[i]
puts "Block: " + info.getBox().to_string + " Text: " + info.getText().to_s
i +=1
end
end
end
|