You can read all the details at: Recognize Image from MemoryStream using OMR in C#
Last active
December 23, 2021 06:27
-
-
Save aspose-com-gists/a9d1baca3598602f46e7d857cc19f730 to your computer and use it in GitHub Desktop.
Recognize Image from MemoryStream using OMR in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get template to recognize | |
string templatePath = "Sheet.omr"; | |
// Get folder contains images for recognize | |
string folderPath = "D:\images\"; | |
OmrEngine engine = new OmrEngine(); | |
// Set template for recognize | |
TemplateProcessor templateProcessor = engine.GetTemplateProcessor(templatePath); | |
// Recognize images from folder | |
Aspose.OMR.Model.RecognitionResult[] result = templateProcessor.RecognizeFolder(folderPath); | |
for (int i = 0; i < result.Length; i++) | |
{ | |
var stringRes = result[i].GetCsv(); | |
File.WriteAllText(folderPath + (i+1) + ".csv", stringRes); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get template to recognize | |
string templatePath = "Sheet.omr"; | |
// Get image for recognize | |
string imagePath = "Sheet1.JPG"; | |
// Initialize OmrEngine class object | |
OmrEngine engine = new OmrEngine(); | |
// Set template for recognize | |
TemplateProcessor templateProcessor = engine.GetTemplateProcessor(templatePath); | |
using (Image image = Image.FromFile(imagePath)) | |
{ | |
using (MemoryStream ms = new MemoryStream()) | |
{ | |
image.Save(ms, image.RawFormat); | |
ms.Flush(); | |
// Recognize image | |
Aspose.OMR.Model.RecognitionResult result = templateProcessor.RecognizeImage(ms); | |
var stringRes = result.GetCsv(); | |
File.WriteAllText(Path.GetFileNameWithoutExtension(imagePath) + ".csv", stringRes); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment