Quickstart
Quickstart
This example generates an OMR form from a template, saves the page image and .omr descriptor, recognizes a scanned copy of that form, and exports the result as CSV.
Full Example
from omr.api import OmrEngine, FormValidationLogic
engine = OmrEngine()
gen = engine.Generate("final-exam.txt") # or a code-first TemplateConfig
gen.Save("out", "final-exam") # -> out/final-exam.png + out/final-exam.omr
processor = engine.GetTemplateProcessor("out/final-exam.omr", FormValidationLogic.Ignore)
result = processor.Recognize("scan.png") # -100 = auto-calibrated threshold
print(result.GetCsv()) # also GetJson() / GetXml()OmrEngine.Generate() accepts either a text-markup DSL source (shown above) or a code-first TemplateConfig tree. GetTemplateProcessor() loads the .omr descriptor it just wrote, and Recognize() reads a scanned image against it. RecognitionResult exports to CSV, JSON, or XML.