– Aspose.OMR Returns ".omr File is Empty" During Recognition:-

Description of the Issue:

I am working on an OMR processing project using Aspose.OMR in C#. The .omr file is generated successfully, and its size is not empty, yet when I try to load and recognize the template, I receive the following error:

:arrows_counterclockwise: Initializing OMR Engine…
:arrows_counterclockwise: Loading OMR Template…
:white_check_mark: OMR Template loaded successfully.
:arrows_counterclockwise: Recognizing the Single Bubble from the Image…
:x: Error: .omr file is empty

Steps to Reproduce the Issue:

  1. Generate the .omr template using Aspose.OMR.
  2. Validate the .omr file:
  • Check its existence: :white_check_mark: (File is present)
  • Check its size: :white_check_mark: (File is not empty)
  • Print first few bytes: :white_check_mark: (File contains JSON data)
  1. Load the template using GetTemplateProcessor().
  2. Attempt to recognize an image (single_filled_corrected.png).
  3. The recognition fails with “.omr file is empty”.

code ‘’’

using System;
using System.IO;
using System.Linq;
using System.Text;
using Aspose.OMR.Api;
using Aspose.OMR.Generation;
using Aspose.OMR.Model;

class Program
{
static void Main()
{
string templatePath = “SingleBubbleTemplate.omr”;
string formImage = “single_filled_corrected.png”;

    Console.WriteLine("📝 Starting OMR Processing...");
    
    try
    {
        GenerateSingleBubbleTemplate(templatePath);

        if (!File.Exists(templatePath) || new FileInfo(templatePath).Length == 0)
        {
            Console.WriteLine("❌ OMR Template file is missing or empty.");
            return;
        }

        Console.WriteLine($"✅ OMR Template created at: {templatePath}, Size: {new FileInfo(templatePath).Length} bytes");

        byte[] omrFileBytes = File.ReadAllBytes(templatePath);
        Console.WriteLine($"🔍 First few bytes of .omr file: {BitConverter.ToString(omrFileBytes.Take(20).ToArray())}");

        if (!File.Exists(formImage))
        {
            Console.WriteLine("❌ OMR filled form image not found.");
            return;
        }

        Console.WriteLine("🔄 Initializing OMR Engine...");
        OmrEngine omrEngine = new OmrEngine();

        Console.WriteLine("🔄 Loading OMR Template...");
        TemplateProcessor templateProcessor = omrEngine.GetTemplateProcessor(templatePath);
        Console.WriteLine("✅ OMR Template loaded successfully.");

        Console.WriteLine("🔄 Recognizing the Single Bubble from the Image...");
        RecognitionResult recognitionResult = templateProcessor.Recognize(formImage);
        Console.WriteLine("✅ OMR Recognition completed.");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"❌ Error: {ex.Message}");
    }
}

static void GenerateSingleBubbleTemplate(string templatePath)
{
    try
    {
        OmrEngine omrEngine = new OmrEngine();
        string omrTemplateText = "SingleBubbleTemplate\n? SingleBubble\n( )";

        using (MemoryStream templateStream = new MemoryStream(Encoding.UTF8.GetBytes(omrTemplateText)))
        {
            GlobalPageSettings pageSettings = new GlobalPageSettings();
            TemplateGenerationResult generateResult = omrEngine.Generate(templateStream, pageSettings);
            File.WriteAllBytes(templatePath, generateResult.Template);
        }

        Console.WriteLine($"✅ OMR Template generated successfully at: {templatePath}");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"❌ Error generating OMR template: {ex.Message}");
    }
}

}
‘’’

Hello, @PriyaRathor10

Can you share .omr and .png? I will investigate them and report findings here.

Dear Aspose Team,

I hope you’re doing well.

I’m currently evaluating Aspose.OMR for an educational and development project. I attempted to request a temporary license via your website, but unfortunately, I was unable to proceed as my email address is from a free domain (e.g., Gmail). I currently don’t have access to a business or custom domain email.

I kindly request if it would be possible to obtain a temporary license manually for the purpose of evaluating the full features of Aspose.OMR before considering a purchase. Your help would be greatly appreciated.

Please let me know if any additional details or verification are required.

Thank you for your support and consideration.

Best regards,
Priya Rathor
India
priya.rathor.266393@gmail.com

Hello, @PriyaRathor10

Aspose OMR require a pre-generated template layout(.omr) as well as presence of reference points in template scan. See article.

Dear Aspose Team,

I hope you’re doing well.

I’m currently evaluating Aspose.OMR for an educational and development project. I attempted to request a temporary license via your website, but unfortunately, I was unable to proceed as my email address is from a free domain (e.g., Gmail). I currently don’t have access to a business or custom domain email.

I kindly request if it would be possible to obtain a temporary license manually for the purpose of evaluating the full features of Aspose.OMR before considering a purchase. Your help would be greatly appreciated.

Please let me know if any additional details or verification are required.

Thank you for your support and consideration.

Best regards,
Priya Rathor
India
priya.rathor.266393@gmail.com

Hello.

I’m sorry to hear that you are having difficulty with the restrictions on requesting temporary licenses. Indeed, now the request is available only for corporate email addresses, but we will promptly solve this problem for you.

I’ve invited a sales team member into this discussion. We will provide you with a temporary license ASAP.

@PriyaRathor10
Please try this one attached.
Aspose.OMR.NET.lic.zip (1.4 KB)

Hi @PriyaRathor10,

Please note that I have shared the Aspose.OMR for .NET Temporary license with priya.rathor.266393@gmail.com, as requested.

Let me know if you need any further assistance.

Best regards,
Marko