public static function set_page_level_threshold($dataDir = null) { # Initialize a string with template file location $template_file = $dataDir . "template.amr"; # Initialize a string with scanned image file location $image_file = $dataDir . "sample_omr.jpg"; # Create an instance of OmrTemplate class and load the template using the factory method Load $omrTemplate = new OmrTemplate(); $omrTemplate = $omrTemplate->load($template_file); # Create an instance of OmrImage class and load the template using the factory method Load $omrImage = new OmrImage(); $omrImage = $omrImage->load($image_file); # Get the first page of the template $page = $omrTemplate->getPages()->getItem(0); # Create page configurations $page->setConfiguration(new OmrConfig()); # Set fill threshold $page->getConfiguration()->setFillThreshold(0.21); # Create an instance of OmrEngine class $engine = new OmrEngine($omrTemplate); # Extract the OMR data $ary = array($omrImage); $result = $engine->extractData($ary); print "Set page level threshold." . PHP_EOL; }
public static function run($dataDir = null) { # Initialize a string with template file location $template_file = $dataDir . "template.amr"; # Initialize a string with scanned image file location $image_file = $dataDir . "sample_omr.jpg"; # Create an instance of OmrTemplate class and load the template using the factory method Load $omrTemplate = new OmrTemplate(); $omrTemplate = $omrTemplate->load($template_file); # Create an instance of OmrImage class and load the template using the factory method Load $omrImage = new OmrImage(); $omrImage = $omrImage->load($image_file); # Set the auto image resolution detection property $omrImage->setAutoDetectResolution(true); # Create an instance of OmrEngine class $engine = new OmrEngine($omrTemplate); # Extract the OMR data $ary = array($omrImage); $result = $engine->extractData($ary); # Get page data of extracted data $pages = $result->getPageData(); $index = 0; # Iterate over the pages and display the data foreach ($pages as $page) { $index += 1; print "------Page: " . (string) $index; $keys = $page->keySet(); $keys = (string) $keys; // $keys = $keys(1, sizeof($keys) - 2); $keys = split(",", $keys); foreach ($keys as $key) { $value = $page->get($key); print "key: " . (string) $key . PHP_EOL; print "value: " . (string) $value . PHP_EOL; } } }