[ Aspose.OMR ] [ Xamarin.Forms ] - System.PlatformNotSupportedException: Operation is not supported on this platform

Hi, @nikita.korobeynikov

I already have the nuget “System.Drawing.Common” version 8.0.0 installed in my Xamarin.Forms project.

In this case, is there no alternative to make it work?

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.

Hi, @nikita.korobeynikov

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.

Happy New Year!

@wilton

Sure, we will inform you as soon as the ticket is resolved. Please spare us little time.

Hello, @wilton

Thank you for your patience!
Aspose.Drawing variation can be found here:
Downloads ---New Releases-aspose.omr-for-.net-23.12-(dlls-only;aspose.drawing)
Please share your results.

Hello, @nikita.korobeynikov

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)

My code:

Aspose.OMR.Api.TemplateProcessor templateProcessor = omrEngine.GetTemplateProcessor(…, Encoding.Default);

Hello, @wilton

Sorry to hear it.
Can you share sample project (.csproj+.cs files)?

Hello, @nikita.korobeynikov

The sample project is attached

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 await your return

Xamarin.Forms_AppSampleCorrector.Android.zip (1,0,MB)

@wilton

Thanks for the information and details. We have updated the logged ticket accordingly and will inform you once we have some updates.

Hello, @wilton

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.

By adding into .csproj file next lines:

  <Target Name="ResolveFix" BeforeTargets="_ResolveAssemblies" >
	<PropertyGroup>
      <TargetFrameworkDirectory>$(TargetFrameworkDirectory);$(SolutionDir)\ResolveFix</TargetFrameworkDirectory>
	</PropertyGroup>

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.

    <PackageReference Include="Aspose.BarCode">
      <Version>23.10.0</Version>
    </PackageReference>
    <PackageReference Include="Aspose.Drawing">
      <Version>23.12.0</Version>
    </PackageReference>
    <PackageReference Include="Aspose.Drawing.Common">
      <Version>23.12.0</Version>
    </PackageReference>
    <PackageReference Include="Aspose.Imaging">
      <Version>23.11.0</Version>
    </PackageReference>
    <PackageReference Include="Aspose.PDF">
      <Version>23.11.0</Version>
    </PackageReference>
  </ItemGroup>

This thread uncovers an important task, the solution for which we will include in the future releases.

Hello, @nikita.korobeynikov

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

Hello, @wilton

I am glad to hear that hotfix is working.

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?

Hello, @nikita.korobeynikov

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.

Images:

Camera:
1 Not work
IMG_CAMERA_Not_work.jpg (253,3,KB)
2 it works
IMG_CAMERA_it _works.jpg (915,8,KB)

Gallery (Compressed) - Not work:
IMG_Compressed_Not_work.jpg (177,5,KB)

Embedded Resource - it works:
IMG_EmbeddedResource_it _works.jpg (206,2,KB)

@wilton

Thanks for providing the files. Please allow us to perform some investigation and we will let you know once we have results.

Hello, @wilton

Thank you for your patience!

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.

Hello, @wilton

We have published a new version of Aspose.OMR for .NET - 24.2.1.
Main change was extended support for small and large scans.

Share with us - did it solved issue with compressed images?

Hello @nikita.korobeynikov,

With this update I can extract from smaller images, is that it?

Answering your question, I’m using a tool to scan the photo and cut the image from the document, so I set the size of the final image to 1200x1800, I’m able to extract the information.

Thank you very much for your help so far

@nikita.korobeynikov

About taking a photo and correctly cropping the document, does aspose have any mobile support for this? I’m using a third-party library because I didn’t find this functionality in aspose. Because without this, there is no way to extract the answers from the answer sheet.

@wilton

Please let us investigate against your feedback and we will get back to you soon.

Hello, @wilton
I have consulted with colleagues - there is no such feature present in OMR or OCR product lines. At the current moment, the best results achieved with scans, where OMR list takes 4\5 of the final image.

There is a TextInWild plugin for OCR, but it targets text, not OMR lists.

For your particular case, I would recommend using phone camera API to look for five black reference points around the corners of the OMR list and zoom to them.