Sha256: fcc82e97a2775c4cb6dbc379236dc68b2e9b98e9dc7981d9da64a00862b6d07b

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

module Asposeocrjava
  module ExtractOmrDataFromImage
    def initialize()
        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)
        
        # Extract the OMR data
        result = engine.extractData(Array[image])
        
        # Get page data of extracted data
        pages = result.getPageData()

        index = 0
        # Iterate over the pages and display the data
        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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asposeocrjava-0.0.1 lib/asposeocrjava/OMR/extractomrdatafromimage.rb