Generate template from existing image to recognize answer options - Aspose.OMR for .NET

@asad.ali

We are not able to process answers and it gives us following error:

System.Exception: Failed to find matching between the template and the image!
at Aspose.OMR.Api.TemplateProcessor.(List`1 , Int32 , Int32 )
at Aspose.OMR.Api.TemplateProcessor.(String , Int32 )
at Aspose.OMR.Api.TemplateProcessor.(String , Int32 )
at Aspose.OMR.Api.TemplateProcessor.RecognizeImage(String imagePath, Int32 recognitionThreshold)

Can you please provide us the steps / criteria to scan using mobile camera / width / height of the image or horizontal and vertical size of the image in pixel to process the answers ?
6ff8cc6d-a608-471c-98a7-2f8ceb6cdf7e.jpg (202.2 KB)

@bvaidya

As shared earlier, this template will work with Aspose.OMR for Cloud instead of Aspose.OMR for .NET because Aspose.OMR for Cloud does not require reference points.

We have tested the scenario in our environment and were not able to find any issue. Please check attached screenshot. CorrectResults.png (712.6 KB) Also, it seems you are using a different image with the template. Would you please share that image with us, so that we can test it in our environment.

We have updated the details of ticket according to this and will share our feedback after investigating the scenario accordingly.

We tried to use FinalBig.omr to process this image and were unable to notice any exception or incorrect results. Please find attached screenshot:
CorrectResults2.png (522.2 KB)

Could you please share the image actually used in this screenshot so that we can test the scenario accordingly.

@asad.ali
Thank you for your time and help, but we are not able to process all images, and more are failing with different errors like template not matching etc.

I have attached all non-processed images. not-processed.zip (2.0 MB)

We are following this code attached.Aspose.OMR.ConsoleDemo.zip (839.2 KB)

Can you please provide us how to scan the images? we are capturing from the mobile devices. Also please provide us the criteria for scanning like the image size, image width and height, image resolutions or the light on the image / shadow on the image while scanning ?

Also please provide your solution (c# code that you process the image without cloud solution and also not using omr client(exe), we need the downloadable c# dll code to process the images.

your help will be appreciated.

@bvaidya

Thank you for sharing requested data.

We are collecting information and will get back to you with our findings soon.

@Farhan.Raza
Thank you for your prompt reply, please do the needful.

@Farhan.Raza & @asad.ali

We need to test all different images, can you please look the issue and fixed and let us know how to properly scan images without error. we are waiting for your reply. we need to urgently fix all issue and provide demo to the client so that we can finalize your omr product and purchse it.

@bvaidya

Thanks for your patience.

We have further investigated the scenario and found that the exception was not caused by the multiple answers but, by the fact that reference points were located very close to the border line - which caused errors during image processing. The best way to deal with such issues is to remove borders completely.

We also advise to use as less borders or additional lines on template as possible (check our test data on Github to see examples of cleaner borderless templates: https://github.com/aspose-omr/Aspose.OMR-for-.NET/tree/master/TestData). If you still want to use borders on image, it is required to move reference points further away from borders to avoid issues.

In the attached archive there are two folders:

  1. LargerSpace, with edited image and template and more space around reference points. Still, there is a possibility that some of poor quality photos may not be recognized. We recommend using NoBorders to avoid issues completely.
  2. NoBorders, which contains edited image and template, as well as several photos demonstrating that with clearly visible reference points almost any kind of image can be recognized. Photo “1.jpg” is rather good quality, while “2.jpg” and “3.jpg” are rotated and curved. Still, it is possible to fully recognize such images.

For some poor quality photos, like “2.jpg” and “3.jpg” it is required to use custom threshold value for bubbles recognition like so:

int customThreshold = 40;
OmrEngine engine = new OmrEngine();
TemplateProcessor templateProcessor = engine.GetTemplateProcessor(templatePath);
RecognitionResult result = templateProcessor.RecognizeImage(imagePath, customThreshold);

This threshold represents the percentage of black pixels in the bubble and surrounding area, which is processed during recognition. Not all images may work perfectly on default value (which is currently set to 45), especially rotated or skewed. In such cases, it is required to find best fitting value to achieve best results. Usually lowering the threshold a bit allows to correctly process such images.

Templates (1).zip (3.5 MB)

We have generated another ticket as OMR-462 in order to investigate against these images and will surely share our feedback as soon as investigation is complete. Please spare us little time.

PS: We were unable to notice any issue with the image (86dcef93-c19b-4655-99c6-3f54d8fbf939.jpg (116.1 KB)) from the archive.

1 Like

@asad.ali
Thank you for your reply, we are working on it and update you the status of scanning.

@asad.ali

We tried with new template but it is not working. I have attached scanned image and the result, so that you can look into this issue.not-processed.JPG (120.9 KB)
2f3fe395-8186-4b08-acf8-efc6469adae7.jpg (94.2 KB)

Also some times following error comes, while processing:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)

threshold-40 we are using.JPG (174.2 KB)

@bvaidya

Regarding this ticket, the issue is the same as in OMR-450: Reference points located too close to borders, which causes them to merge during image processing. Thus, reference points can’t be detected and exception occurs. To avoid this:

  • Make sure that reference points has enough blank space around them
  • Reference points should be clearly seen on photo (for example, on image 1ceaeeb0-57ad-45f1-b97a-62dde919f659 from archive one of the points is cut, thus making this photo unprocessable).

We have already shared templates with same image but no bounds and another template with larger spacing.

We will check this and will let you know about our findings. Please spare us little time.

@asad.ali

I tried with your new template largespace, but from iPad I scan the image and it gives us template not matching error.

d7be549d-5219-41a0-82f1-1171bf5af575.jpg (146.7 KB)

Error: Failed to find matching between the template and the image!

As per your instruction, this attached image has four reference points with enough space around it. But still it can not recognize.

@bvaidya

We will look into this and will let you know as soon as investigation is complete. Please note that a new version of the API has been released which offers template generation functionality from simple text markup. We are working over adding examples in public documentation and will share with you as soon as process is completed.

@asad.ali

Thank you for your reply, but as per our requirement we do not need to use API. We need background c# code that can process the image. You sent us new template with enough space outer the black square reference point, but still that image is also not processed. I have already shared that image capture from the mobile and the error - “Failed to match template”. We are not able to recognized the image with new template. Can you please look into this issue as soon as possible. We are follow-up with you since may 2019. and we are not come to any point where we can find the solution. please provide concrete solutions.

@bvaidya

We have observed your comments and are gathering information in order to share with you according to your concerns. We will get back to you soon. Please spare us little time.

@asad.ali

Have you resolved the issue we are facing, we are stuck on scanning / processing omr sheets using c# downloadable project, can you please do the needful to work on ?

@bvaidya

The ticket is still pending and investigation is underway. We will surely let you know as soon as there is some updates regarding its resolution. Please spare us little time.

We are sorry for the inconvenience.

@asad.ali

We are waiting for the solution for processing omr sheet that you provided, but it is not still recognizing. Can you please do the needful.

@bvaidya

The major cause of the issue appeared to be image pre-processing, which caused some of the reference points gone missing. This was fixed by changing the binarization algorithm. Tests show that images are now successfully recognized. Changes will appear in production in 2019.08 release scheduled to the end of the month.

@asad.ali
Thank you for your reply, when your changes will appear in production for 2019.08 release? can you please provide me link to download that new solution and test ?

Please do the needful.

@bvaidya

The new version of the API is currently on its way to be published. As soon as it is released, we will share with you.