Hello, I am trying to recognize an image with browns.omr in a Xamarin.forms application, but I am receiving an exception of error saying, “System.platformnotsupportexception: Operation is not supported on this platform.”
How can I get around this problem? Please help me.
Log:
“type”: “System.PlatformNotSupportedException”,
“message”: “Operation is not supported on this platform.”,
“stackTrace”: " at System.Drawing.Image.FromStream (System.IO.Stream stream) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/Facades/System.Drawing.Common/Stubs.cs:724
at \b\u0015\u0005.\u0002 (System.IO.Stream \u0002) [0x00000] in <4631df33c0e74db80b7b9b239680ef58>:0
at Aspose.OMR.Api.TemplateProcessor.\u0003 (\u0002\u0005\u000f \u0002, System.Int32 \u0003, System.String \u0005) [0x0001c] in <4631df33c0e74db80b7b9b239680ef58>:0
at Aspose.OMR.Api.TemplateProcessor.\u0002 (\u0002\u0005\u000f \u0002, System.Int32 \u0003, System.String \u0005) [0x00035] in <4631df33c0e74db80b7b9b239680ef58>:0
at Aspose.OMR.Api.TemplateProcessor.RecognizeImage (System.IO.MemoryStream stream, System.Int32 recognitionThreshold) [0x00014] in <4631df33c0e74db80b7b9b239680ef58>:0
Aspose.OMR.Api.OmrEngine omrEngine = new Aspose.OMR.Api.OmrEngine();
Aspose.OMR.Api.TemplateProcessor templateProcessor = omrEngine.GetTemplateProcessor(GetTemplateFile(), Encoding.Default);
My Code:
var streamImage = await CurrentFileResult.OpenReadAsync();
MemoryStream memoryStream = new MemoryStream();
streamImage.CopyTo(memoryStream);
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): OMRNET-933
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Thank you for the wait.
Please try following fixes:
Install “System.Drawing.Common” NuGet package in the same project as “Aspose.OMR”.
or
Use other implementation versions (.net5.0.net6.0.net7.0) of the library.
If neither of the fixes help - we are also planning a version of Aspose.OMR with alternative drawing engine. Instead of System.Drawing it will be using Aspose.Drawing. It proved to be more dependable in non-windows platforms.
Hello, @wilton
I can only recommend Aspose.OMR version with Aspose.Drawing. We plan it to be published in the end of the December 2023 or start of January 2024.
I will post additional notification in this thread.
I will be waiting for the notification when this update is released. Because we paid a very high amount for the license and we will only be able to use it when it this feature released. It’s very important for us.
Now I can’t even get to the Recognize method, an error is already occurring when loading the template, the app is already crashing at this point:
Exception:
Could not load signature of : due to: Could not resolve type with token 01000035 from typeref (expected class ‘Aspose.Drawing.Rectangle’ in assembly ‘Aspose.Drawing, Version=23.1.0.0, Culture=neutral, PublicKeyToken =716fcc553a201e56’) assembly:Aspose.Drawing, Version=23.1.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56 type:Aspose.Drawing.Rectangle member:(null)
Add a license and dll to the folders:
…\AppSampleCorrector\Resources\Aspose.OMR.NET.lic
…\DLL_AsposeOMR\netstandard2.0\Aspose.OMR.dll
Just to update you, this dll you sent causes 2 errors:
1 - When trying to load the license:
System.TypeLoadException: ‘Value type instance size (1311768) cannot be zero, negative, or bigger than 1Mb’
2 - When trying to load the template:
Could not load signature of : due to: Could not resolve type with token 01000035 from typeref (expected class ‘Aspose.Drawing.Rectangle’ in assembly ‘Aspose.Drawing, Version=23.1.0.0, Culture=neutral, PublicKeyToken =716fcc553a201e56’) assembly:Aspose.Drawing, Version=23.1.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56 type:Aspose.Drawing.Rectangle member:(null)
I have investigated the project you provided. The problem appears to be in a unique approach at assembly resolve in Xamarin build implementations. Xamarin require full transitive dependency resolution, which are the reason for “Could not resolve” errors during build.
I have updated a sample solution with a workaround (link for archive in private messages) for Android, which I suppose can be copied for iOS also.
We are injecting into dll paths an extra folder - “ResolveFix”, which can be found in the root of the solution. Inside this folder are reference assemblies which are used during build of the solution, but do not participate in final artifacts and do not intertwine with Aspose.OMR library.
This process also does not affect the resulting .apk file.
Also, I have removed all references to Aspose.Drawing\PDF\Imaging .etc. These dependencies are meant to be internal and are not required for Aspose.OMR working process.
It really solved the problem of loading the license file and template, but I’m running into another problem.
I gave you a prototype with 3 ways to read the image, through the camera, through the gallery and by opening an Embedded Resource file for the project. Only the third option works, the others give me the following error, even opening the same image from the gallery doesn’t work:
Exception:
Failed to find all reference points on image! Please make sure they are clearly visible and have enough blank space around them.
at p. ( ) [0x0004e] in <180ae9d6770546d8863d197c62d4a9a3>:0
at p. ( , ) [0x00000] in <180ae9d6770546d8863d197c62d4a9a3>:0
at p. ( , , , System.Int32 ) [0x0001b] in <180ae9d6770546d8863d197c62d4a9a3>:0
at Aspose.OMR.Api.TemplateProcessor. ( , System.Int32 , System.String ) [0x00056] in <180ae9d6770546d8863d197c62d4a9a3>:0
at Aspose.OMR.Api.TemplateProcessor. ( , System.Int32 , System.String ) [0x00035] in <180ae9d6770546d8863d197c62d4a9a3>:0
at Aspose.OMR.Api.TemplateProcessor.Recognize (System.IO.Stream stream, System.Int32 recognitionThreshold) [0x00014] in <180ae9d6770546d8863d197c62d4a9a3>:0
From your description, it appears to be that streams passed to Recognize method are different from embedded\gallery\camera modes.
Can you extract and share images from camera\gallery before they send to Aspose.OMR Recognize method?
I’m sending the images as attachments, I noticed that the gallery image is being compressed by 75%, but it’s not losing quality, and even so aspose doesn’t read the image.
Regarding the camera, I noticed that if the photo is a little crooked, aspose won’t read the image either. I’ll test a plugin that crops the photo, leaving the document in a better position for reading.
I have investigated samples you provided, and I can confirm that “not_work” samples are failing at recognition because of small dimensions. Library are not suited for 600x900 scans - it is considered to be too small at the moment. Exact bottom line dimensions are hard to tell, because of difference in image quality, but I would recommend images to be at least 1200x1800.
We are planning this year a release with support for smaller scans. As a temporary workaround, I would recommend decreasing compression of images in camera.