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

@jamesanvictoria

Certainly!

BufferedImage, InputStream and their subclasses can be used as input parameters
In the new API entries for TemplateProcessor.recognizeImage methods.


        InputStream inputStream = new FileInputStream(imagePath);

        OmrEngine engine = new OmrEngine();
        TemplateProcessor tp = engine.getTemplateProcessor(templatePath); 
        RecognitionResult rr = tp.recognizeImage(inputStream, 40);

        BufferedImage bufferedImage = javax.imageio.ImageIO.read(new File(imagePath));

        OmrEngine engine = new OmrEngine();
        TemplateProcessor tp = engine.getTemplateProcessor(templatePath); 
        RecognitionResult rr = tp.recognizeImage(bufferedImage , 40);

Hi @nikita.korobeynikov

I can confirm it works like a charm.

Many thanks again.

BTW, I have another sheet which requires template file. Do you mind creating .omr file for me?

Cheers,

Hello, @jamesanvictoria

Glad to be of assistance!
Not at all - send details here and I will create .omr file.

In a couple days there will be an update for OMR sheet designer. In new version there will be a support for different layouts and versions of OMR.

Hi @nikita.korobeynikov

Thank you as always for your collaboration.

I have a question regarding the orientation of scanned images.

Currently, we are uploading scanned images in the correct orientation, but sometimes some images are uploaded upside down, which causes detection issues.

From my understanding, the four squares in the corners help detect the scope of the sheet, but not its orientation. (Please correct me if I’m mistaken.)

Is there any way to allow the system to accept and properly process answer sheets that are scanned upside down as well?

Thank you in advance for your advice.

Hello, @jamesanvictoria

Glad to be of assistance!

We have a solution for .NET version of the library in the form of the fifth rotation point.

For Java version, there is no solution or workaround at the moment.
I will investigate it and post an estimate and release dates for the rotation support in Java.

Hi @nikita.korobeynikov,

Many thanks to your co-work again and please feel free to let me know your update all the time.

Cheers,

@jamesanvictoria,

I have added this in immediate development queue. I expect this to be ready in one or two weeks.
I will post updates, if timetable is shifted.

Hi @nikita.korobeynikov
I hope this message finds you well.
I have a quick question regarding the student ID recognition process. I’ve noticed that in some cases, the system fails to detect student IDs on the answer sheets. I’m wondering if this issue might be related to the OMR template, or if there are any adjustments we can make to improve the recognition rate.
FYI, I am using

BufferedImage image = renderer.renderImageWithDPI(i, 300, ImageType.RGB); // dpi 300
RecognitionResult processResult = megaProcessor.recognizeImage(image, 32); // omr_threshold 32

Any insights or suggestions you could share would be greatly appreciated.

Screenshot 2025-08-08 at 3.45.59 pm.png (223.0 KB)

Screenshot 2025-08-08 at 3.48.00 pm.jpg (187.8 KB)

Screenshot 2025-08-08 at 3.49.37 pm.jpg (196.4 KB)
test.zip (346.0 KB)

No worries for the above, i got the solution by increasing dpi in image.

BufferedImage image = renderer.renderImageWithDPI(i, 320, ImageType.RGB); // dpi from 300 to 320)

Cheers,

Hello, @jamesanvictoria

Glad it was resolved!
Images in PDF file in test.zip seems to be in good quality. Can you share images with 300 dpi that were not properly recognized? I would like to investigate for recognition improvement, if possible.

Regarding rotation support:
I believe this feature will be ready next week and published in 25.8 release of Aspose OMR for Java.

There will be breaking changes to API:

  1. New reference point, that will be used for rotation detection. The resulting template image will be the same as with .NET version - https://releases.aspose.com/omr/net/release-notes/2022/markers.png
  2. Content of .omr file will change as well, to accommodate new rotation support.

I will post exact changes in release notes.

Hi @nikita.korobeynikov,

I wanted to update you on the DPI issue we discussed. I found that the 300 DPI value was hardcoded in the image processing code (BufferedImage class) rather than being related to the actual scanner settings. I’ve resolved the recognition clarity issue by increasing the BufferedImage DPI value from 300 to 320 in the code. Hence, thanks but no further investigation is needed on this matter.

Regarding the rotation support feature, I greatly appreciate your assistance. I amy reach out again in the future for help with generating a new PDF implementation (there is no immediate urgency for this).

Thank you for your cintined support.

Regarding rotation support, I appreciate to your support again and may ask co-operation to generate new pdf later. (No rush)

Cheers,

@jamesanvictoria

Glad to be of assistance!

Hello, @jamesanvictoria

Release 25.8 for Java is ready: Aspose.OMR for Java 25.8.0 - Release Notes

New extended support for rotation will require changes in .omr files and template images. Please post template images and .omr - I will update them to 25.8.

Thank you for taking interest in our product!

Hi @nikita.korobeynikov

It’s good to hear new version is ready.

We are exited to apply new features and here are omr template and images. (Mega & TT)

omrl.zip (656.4 KB)

Many thanks to your co-work in advance.

Cheers,

Hello, @jamesanvictoria

I have updated templates to be compatible with Aspose OMR for Java 25.8.
OMRJAVA-97-TopRight1.zip (4.8 MB)

I have used a TopRight1 position for rotation marker.