Quickstart
Bắt đầu nhanh
Ví dụ này tạo một biểu mẫu OMR từ mẫu, lưu ảnh trang và .omr descriptor, nhận dạng bản sao quét của biểu mẫu đó, và xuất kết quả dưới dạng CSV.
Ví dụ đầy đủ
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() chấp nhận một nguồn DSL đánh dấu văn bản (được hiển thị ở trên) hoặc một cây TemplateConfig code-first. GetTemplateProcessor() tải .omr descriptor mà nó vừa viết, và Recognize() đọc một hình ảnh đã quét dựa trên nó. RecognitionResult xuất ra CSV, JSON, hoặc XML.