How to create OMR template file (.omr) using existing image in Java

Hello, @jamesanvictoria

I have converted pdf with Aspose online-tool.
Using OMR Cloud Client offline features, I have marked up bubbles with samples your provided.

See results (4.2 MB)

OMR Cloud client is accessed through SID and KEY, which can be received either through purchase of a license or a free trial.
Instruction for free trial (325.3 KB)
OMR Client interface (161.8 KB)

Hi @nikita.korobeynikov

First of all, many thanks again for your co-work.

Apologies for the continued questions. I’m currently using a Mac, so I’m unable to install the OMR Cloud Client on my laptop.

I was wondering—when using an OMR sheet with four corner square markers, does the OMR Cloud Client export the output exclusively in JPG format, or is PDF also supported?

Cheers,

Hello, @jamesanvictoria

Unfortunately, OMR Cloud Client was outputting only image(jpg) and .omr file.

Regarding, template markup - I’ll discuss this with my team to see how we can best assist you.
I will post an estimate on new features here later on.

Hi @nikita.korobeynikov,

Thank you for your continued support — I truly appreciate your assistance.
However, I must admit I’m feeling a bit frustrated, as I’m unable to use the OMR Cloud Client on my Mac, which limits my ability to test and validate outputs directly.

I understand you’re generating results on my behalf, but it’s essential that we guarantee the highest quality PDF output for the students’ answer sheets — image files of lower resolution won’t meet our professional standards.

Additionally, I’ve noticed that the square corner markers are slightly overlapping, which makes the borders appear misaligned and less polished.
overlappiing.pdf (2.0 MB)

Would you mind re-generating both the template files and the output images in the highest possible resolution for us? (then I will convert them into the hightest resolution PDF)
For TT6 TT8 JMSS VSSE_wo_logo.pdf (313.6 KB)

For TT6 TT8 JMSS VSSE_with_logo.pdf (752.0 KB)

For MEGA Revision_with_logo.pdf (469.7 KB)

For MEGA Revision_wo_logo.pdf (373.1 KB)

For your reference, we’ve made a few slight adjustments to the sheets. I’ll reattach 4 updated versions in this message.

Thanks in advance for your cooperation — I really appreciate your collaboration on this.

Hello, @jamesanvictoria

Thank you for your interest in our product!

I am sorry that OMR Cloud client was not helpful. We will present a better template generation tools in the future. These tools will replace OMR Cloud client and will be able to accommodate your needs.
I will post details later on.

In the meantime, I am attaching one of the templates with added reference points as vector PDF file and correlating .omr template file for Aspose OMR Java.

OMRJAVA-97-For MEGA Revision_with_logo.zip (292.6 KB)

Please test this template and .omr. Depending on results, I will process others as well.

Hi @nikita.korobeynikov,

Many thanks to your update and work again !
Sorry but I realised that posted image were out dated one.
Please ignore what I uploaded before, let me attach again.

I really appreciate to your work for me.

For MEGA Revision_with_logo.pdf (1.4 MB)

For TT6 TT8 JMSS VSSE_with_logo.pdf (1.1 MB)

For TT6 TT8 JMSS VSSE_wo_logo.pdf (707.4 KB)

For MEGA Revision_wo_logo.pdf (545.6 KB)

@jamesanvictoria

No problem. I will post results in this thread, once I am done processing them.

Hello, @jamesanvictoria

Thank you for your patience!

In the attachment there is a vector PDF with reference points and .omr file. All files are tested and are ready to be used in Aspose OMR for Java.
result.zip (2.5 MB)

Could you share a brief update on whether templates were useful? Thank you!

1 Like

Hi @nikita.korobeynikov

This is a significant improvement over the previous work and looks very professional !
I will schedule some testing sessions with other team next week and will let you know how everything peerforms.
Thanks you in advance for your collaboration.

1 Like

Hi @nikita.korobeynikov,

I am going to call TemplateProcessor.recognizeImage() method to process scanned image.

It takes String as file path but I get the image from BufferedImage in the memory.

In this case, can you please advise how to invoke method? In additon, is there any reference for API documenation?

Here is the snippet for your understanding.

// render the PDF page to an image with 100 DPI JPG format
BufferedImage image = renderer.renderImageWithDPI(i, 100, ImageType.RGB);
// Process the image using Aspose OMR
try {
// Create recognition results from the image, it throws the error as recognizeImage takes String path
RecognitionResult[] results = megaProcessor.recognizeImage(image);

Many thanks in advance.
Cheers,

Hello, @jamesanvictoria

Unfortunately, OMR Java supports only String input parameter at the moment.
I have added this feature into development queue and post detail here later on.

As a temporary workaround, I can recommend writing BufferedImage to file system:

        OmrEngine engine = new OmrEngine();
        //creating a temp file, using Java API
        File tempFile = File.createTempFile("OMR-Temp", ".png");
        //writing content of BufferedImage into temp file
        javax.imageio.ImageIO.write(bufferedImage, "png", tempFile);

        TemplateProcessor tp = engine.getTemplateProcessor(templatePath);
        //calling Recognize API using absolute path to temp file
        RecognitionResult rr = tp.recognizeImage(tempFile.getAbsolutePath(), 40);

Aspose OMR Java API located here - com.aspose.omr | Aspose.OMR for Java API Reference

Hi @nikita.korobeynikov
Understood. I stongly believe reading from memory directly is essential for future development so hopefully see any update for this soon.
By the way, I tested sample code but it prints out only parital part rather than the whole answer sheets.
For your information, here is the snippet what I wrote and the relavant results.

// process Mega/Revision sheet
private void processMega(String fileName){
// Use the file from static directory
String staticPath = “src/main/resources/static/assets/pdf/” + fileName;
// Process the file
RecognitionResult result = megaProcessor.recognizeImage(staticPath, 40);
System.out.println("getCsv() : " + result.getCsv());
System.out.println("getJson() : " + result.getJson());
System.out.println("getOmrElement() : " + result.getOmrElements());
System.out.println("getTemplateName() : " + result.getTemplateName());
}

===========================================================
getCsv() : Element Name,Value,
Question1,“B”
Question2,“C”
Question3,“C”
Question4,“B”
Question5,“A”

getJson() : {
“RecognitionResults”: [
{
“ElementName”: “Question1”,
“Value”: “B”
},
{
“ElementName”: “Question2”,
“Value”: “C”
},
{
“ElementName”: “Question3”,
“Value”: “C”
},
{
“ElementName”: “Question4”,
“Value”: “B”
},
{
“ElementName”: “Question5”,
“Value”: “A”
}
]
}
getOmrElement() : com.aspose.omr.lf.l0p@68573a6
getTemplateName() : For MEGA Revision_with_logo_2

FYI, I bought the liscent recently. (23/05/2025)

Hello, @jamesanvictoria

I agree that reading from memory is essential. I will add this feature ASAP - approximately in the next week as a new Java release.

Regarding missing questions, were there a line’s that sets license? For example:

        License license = new com.aspose.omr.License();
        license.setLicense("C:\\Users\\User\\Desktop\\OMR\\Aspose.OMR.Java.lic");

        OmrEngine engine = new OmrEngine();

These lines must be called each time application is Aspose OMR for Java is used, ideally before OmrEngine initialization.

Thank you so much for purchasing OMR for Java! I’m truly honored you chose our solution and sincerely hope it brings you great value and ease in your projects.

Hi @nikita.korobeynikov

Yes, I initialise license in the constructor block as below.

private OmrEngine engine;

private License omrLicense;

private TemplateProcessor megaProcessor;

private TemplateProcessor ttProcessor;


public OmrServiceImpl() {
omrLicense = new License();
try {
omrLicense.setLicense(“src/main/resources/omr/Aspose.OMR.Java.lic”);
} catch (Exception e) {
e.printStackTrace();
}
engine = new OmrEngine();
megaProcessor = engine.getTemplateProcessor(“src/main/resources/omr/MEGA.omr”);
ttProcessor = engine.getTemplateProcessor(“src/main/resources/omr/TT.omr”);
}

And confirmed license contains with xml tags

LicenseType : Developer OEM
LicenseNote :1 Developer And Unlimited Deployment Locations

Do I need to ask new license file?

Your feedback will be highly appreciated.

Screenshot 2025-06-19 at 9.30.08 am.png (91.8 KB)

@jamesanvictoria

Sorry to hear that there is an issue.
I have created a sample project for intellij IDEA, in attachment below. Is it working properly?
If sample project returning CSV with all questions - could you create an example project with this issue, that I could debug?
Thank you!

OMRJAVA-97-example-2.zip (2.8 MB)

Hi @nikita.korobeynikov

I could get proper result from your code with my purchased license so may not be an issue with purchased license.
However, when I ran my example (mega.jpg & mega.omr) under the same environment, it still generates only partial result (mega.csv).
Can you please confirm it ?
Many thanks to your co-work in advance.

OMRJAVA-Jin-example.zip (3.6 MB)

P.S> I realised it gets all question list - not only up to first 5 - even values are incorrect if I switch the aspose library from 24.5 to 24.12. (I guess values inconsistency might be based on wrong .omr file when I ran. I will verify this soon.)
Please see the scanned sheet and result csv the below.
Screenshot 2025-06-19 at 5.19.43 pm.jpg (203.8 KB)

Hello, @jamesanvictoria

Thank you for your patience!

I have investigated attached project.
Regarding licensing, your newly generated license is using a new encryption algorithm. Support for it was introduced in 24.12. So using it with earlier versions will result in licensing failure and limit to 5 first elements.

Regrading incorrect answers, I believe the issue is with a different .omr file.
mega.jpg was created using a “For MEGA Revision_with_logo”, but mega.omr is created for “For TT6 TT8 JMSS VSSE_with_logo”.
To verify, one can look at “Name” key inside .omr file content.

Also, I have noticed that student_number field were marked with smaller marks, like number “3”. I would recommend using a value of “30” for recognition threshold parameter to capture them.

Hi @nikita.korobeynikov

Thanks for your guide.

Yes, it works like a charm with 24.12 and I could get expected result with proper omr file. Thanks again.

In the meanwhile, is it possible to make group of result set?

For example, I have 3 subjects so want to make Group 1 [Q1~Q30] , Group 2 [Q1~Q30], Group 3 [Q1-Q30] rather than the whole list covering from Q1~Q90 like below.

getCsv() : Element Name,Value,
Question1,“B”
Question2,“C”
Question3,“C”
Question4,“B”
Question5,“A”
Question6,“B”
Question7,“B”
Question8,“D”
Question9,“C”
Question10,“C”
Question11,“C”
Question12,“C”
Question13,“A”
Question14,“B”
Question15,“A”
Question16,“A”
Question17,“B”
Question18,“B”
Question19,“D”
Question20,“D”
Question21,“D”
Question22,“”
Question23,“B”
Question24,“A”
Question25,“D”
Question26,“A”
Question27,“D”
Question28,“B”
Question29,“C”
Question30,“B”
Question31,“B”
Question32,“B”
Question33,“A”
Question34,“A”
Question35,“B”
Question36,“C”
Question37,“D”
Question38,“”
Question39,“C”
Question40,“A”
Question41,“B”
Question42,“B”
Question43,“B”
Question44,“D”
Question45,“C”
Question46,“B”
Question47,“B”
Question48,“D”
Question49,“D”
Question50,“A”
Question51,“D”
Question52,“C”
Question53,“B”
Question54,“D”
Question55,“C”
Question56,“B”
Question57,“A”
Question58,“B”
Question59,“”
Question60,“”
Question61,“D”
Question62,“C”
Question63,“D”
Question64,“D”
Question65,“D”
Question66,“A”
Question67,“A”
Question68,“D”
Question69,“B”
Question70,“B”
Question71,“A”
Question72,“C”
Question73,“D”
Question74,“D”
Question75,“C”
Question76,“B”
Question77,“A”
Question78,“C”
Question79,“A”
Question80,“C”
Question81,“A”
Question82,“C”
Question83,“A,C”
Question84,“B”
Question85,“”
Question86,“C”
Question87,“A”
Question88,“C”
Question89,“”
Question90,“B”

mega.pdf (1.7 MB)

I think almost get there thanks to your heaps of help !

@jamesanvictoria

I have updated each .omr file. Divided them into 2 and 3 groups:
Group_1_Q1 - Group_3_Q30
Group_1_Q1 - Group_2_Q60

Added .jpeg version of template I used for reference.
OMRJAVA-97-3.zip (8.3 MB)

Glad to be of assistance!

Hi @nikita.korobeynikov

Awesome — thank you so much for your continued support!

Your work has saved us a great deal of time on our side.

I’d like to ask for some advice regarding the recognizeImage(String imagePath, int recognitionThreshold) method.

I’m still not entirely clear on what the ideal threshold value should be, so I’ve been using 30, based on your earlier recommendation.

However, with this setting, it appears that some answers — specifically from the 6th and 7th sheets in my sample file — were not recognized.

Could you please advise how I might adjust the threshold to ensure all answers are included?

tt_10.zip (3.0 MB)

FYI, I am using ‘For TT6 TT8 JMSS VSSE_with_logo.omr’ template for this.

Cheers,