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
39
40
41
42
43
|
# File 'lib/asposeocrjava/OMR/extractomrdatafromimage.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
template_file = data_dir + "template.amr"
image_file = data_dir + "sample_omr.jpg"
template = Rjb::import('com.aspose.omr.OmrTemplate').load(template_file)
image = Rjb::import('com.aspose.omr.OmrImage').load(image_file)
engine = Rjb::import('com.aspose.omr.OmrEngine').new(template)
result = engine.(Array[image])
pages = result.getPageData()
index = 0
pages.each do |page|
index +=1
puts "------Page: " + index.to_s
keys = page.keySet()
keys = keys.to_string
keys = keys[1, keys.length - 2]
keys = keys.split(",")
keys.each do |key|
value = page.get(key)
puts "key: " + key.to_s
puts "value: " + value.to_s
end
end
end
|