AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Problem using difference(image) in UWP

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

Problem using difference(image) in UWP

Postby FMorsch » Tue Dec 12, 2017 9:47 am

Hello,

im currently programming a simple UWP with some uses of the portable.aforge.
On of the things i do is checking a image for ist colors, to get the correct region i take a reference picture and a picture in which colors have changed, convert them to grayscale and create a difference image. Then i use a threshold filter on it. It works fine in debugging mode, but when i try to use the release version i get this

1>C:\Users\morsch\.nuget\packages\microsoft.net.native.compiler\1.7.2\tools\Microsoft.NetNative.targets(697,5): warning : MCG : warning MCG0007: Unresolved P/Invoke method 'ntdll.dll!memcpy' for method 'System.Byte* AForge.SystemTools.memcpy(System.Byte*, System.Byte*, System.Int32)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisify those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.

1>C:\Users\morsch\.nuget\packages\microsoft.net.native.compiler\1.7.2\tools\Microsoft.NetNative.targets(697,5): warning : MCG : warning MCG0007: Unresolved P/Invoke method 'ntdll.dll!memset' for method 'System.Byte* AForge.SystemTools.memset(System.Byte*, System.Int32, System.Int32)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisify those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.

So the difference filter (and maybe some other funtions?) uses memcpy and memset from the ntdll.dll, which after this documentation
https://msdn.microsoft.com/de-de/library/windows/desktop/mt186422(v=vs.85).aspx
are not supported by windows UWP.

Any tips how i could get it to work? Since the portable.aforge is designed to get along with UWP, i thought maybe someone here knows a solution to the Problem.

Best regards and thanks for any help
FMorsch
 
Posts: 3
Joined: Tue Dec 12, 2017 9:34 am

Re: Problem using difference(image) in UWP

Postby andrew.kirillov » Tue Dec 12, 2017 6:56 pm

Hello,

You will need to do minor changes to the source code of the framework. Check the SystemTools.cs. Find all code like:
Code: Select all
#if !MONO
...
#else

Remove that all. So in short, you should not use memcpu() or memset() from ntdll.dll. Just use native code.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Problem using difference(image) in UWP

Postby FMorsch » Wed Dec 13, 2017 9:55 am

First, i want to thank you for the fast help.

Now i have another problem, given that im a beginner in programming: how can i install the aforge package manually?

I only installed it with the NuGet-Manager and downloaded it directly, but if i do so i cant change the SystemTools.cs, can i?

So now i downloaded the AForge-master file, but how do i install this? Sorry to bother with such a simple question :/
FMorsch
 
Posts: 3
Joined: Tue Dec 12, 2017 9:34 am

Re: Problem using difference(image) in UWP

Postby andrew.kirillov » Wed Dec 13, 2017 10:56 am

You need to get source code and build it. Then put AForge.NET assemblies where you need them to be.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Problem using difference(image) in UWP

Postby FMorsch » Wed Dec 13, 2017 12:02 pm

Thanks for the help, i really appreciate it :)
FMorsch
 
Posts: 3
Joined: Tue Dec 12, 2017 9:34 am




Return to AForge.NET Framework