Last active
August 6, 2021 04:13
-
-
Save aspose-com-gists/84c0f9fd33379d21e68132bd1333b570 to your computer and use it in GitHub Desktop.
Create OMR Sheet Checker or Scanner with Java | https://blog.aspose.com/2021/08/05/create-omr-sheet-checker-or-scanner-with-java/
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
Read the complete article about creating OMR sheet checker or scanner with Java by visiting the following link. | |
https://blog.aspose.com/2021/08/05/create-omr-sheet-checker-or-scanner-with-java/ |
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
// Source and output directory paths | |
String sourceDirectory = "SourceDirectory\\OMR\\Generation\\"; | |
String outputDirectory = "OutputDirectory\\"; | |
// Create an instance of the OmrEngine class | |
OmrEngine engine = new OmrEngine(); | |
// Generate template using the text markup | |
GenerationResult res = engine.generateTemplate(sourceDirectory + "Grid.txt"); | |
// Check in case of errors | |
if (res.getErrorCode() != 0) | |
{ | |
System.out.println("ERROR CODE: " + res.getErrorCode()); | |
} | |
// Save the generation result: image and .omr template | |
res.save(outputDirectory, "Grid"); |
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
// Source and output directory paths | |
String sourceDirectory = "SourceDirectory\\OMR\\"; | |
String outputDirectory = "OutputDirectory\\"; | |
String TemplateName = "Sheet.omr"; | |
String[] UserImages = new String[] { "Sheet1.jpg", "Sheet2.jpg" }; | |
String[] UserImagesNoExt = new String[] { "Sheet1", "Sheet2" }; | |
// Create an instance of the OmrEngine class | |
OmrEngine engine = new OmrEngine(); | |
// Load the template file | |
TemplateProcessor templateProcessor = engine.getTemplateProcessor(sourceDirectory + "Sheet.omr"); | |
System.out.println("Template loaded."); | |
// Loop through the images | |
for (int i = 0; i < UserImages.length; i++) { | |
// Recognize image and receive result | |
RecognitionResult result = templateProcessor.recognizeImage(sourceDirectory + UserImages[i]); | |
// Export results as csv string | |
String csvResult = result.getCsv(); | |
// Save csv to the output folder | |
PrintWriter wr = new PrintWriter(new FileOutputStream(outputDirectory + UserImagesNoExt[i] + ".csv"), true); | |
wr.println(csvResult); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment