Module: Asposeocrjava::SetMarkThreshold

Defined in:
lib/asposeocrjava/OMR/setmarkthreshold.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
# File 'lib/asposeocrjava/OMR/setmarkthreshold.rb', line 3

def initialize()
    # Setting Global Threshold
    set_global_threshold()

    # Setting Page Level Threshold
    set_page_level_threshold()
end

#set_global_thresholdObject



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
# File 'lib/asposeocrjava/OMR/setmarkthreshold.rb', line 11

def set_global_threshold()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
            
    # Initialize a string with template file location
    template_file = data_dir + "template.amr"
    
    # Initialize a string with scanned image file location
    image_file = data_dir + "sample_omr.jpg"
    
    # Create an instance of OmrTemplate class and load the template using the factory method Load
    template = Rjb::import('com.aspose.omr.OmrTemplate').load(template_file)
    
    # Create an instance of OmrImage class and load the template using the factory method Load
    image = Rjb::import('com.aspose.omr.OmrImage').load(image_file)

    # Create an instance of OmrEngine class
    engine = Rjb::import('com.aspose.omr.OmrEngine').new(template)

    # Get the configurations of OmrEngine
    config = engine.getConfiguration()

    # Set fill threshold
    config.setFillThreshold(0.12)

    # Extract the OMR data
    result = engine.extractData(Array[image])

    puts "Set global threshold."
end

#set_page_level_thresholdObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/asposeocrjava/OMR/setmarkthreshold.rb', line 41

def set_page_level_threshold()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
            
    # Initialize a string with template file location
    template_file = data_dir + "template.amr"
    
    # Initialize a string with scanned image file location
    image_file = data_dir + "sample_omr.jpg"
    
    # Create an instance of OmrTemplate class and load the template using the factory method Load
    template = Rjb::import('com.aspose.omr.OmrTemplate').load(template_file)
    
    # Create an instance of OmrImage class and load the template using the factory method Load
    image = Rjb::import('com.aspose.omr.OmrImage').load(image_file)

    # Get the first page of the template
    page = template.getPages().getItem(0)

    # Create page configurations
    page.setConfiguration(Rjb::import('com.aspose.omr.OmrConfig').new)

    # Set fill threshold
    page.getConfiguration().setFillThreshold(0.21)

    # Create an instance of OmrEngine class
    engine = Rjb::import('com.aspose.omr.OmrEngine').new(template)

    # Extract the OMR data
    result = engine.extractData(Array[image])

    puts "Set page level threshold."
end