Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load DlibDotNetNativeDnn in Blazor WebAssembly project #303

Open
alexsosa2000 opened this issue Jul 6, 2023 · 0 comments
Open

Can't load DlibDotNetNativeDnn in Blazor WebAssembly project #303

alexsosa2000 opened this issue Jul 6, 2023 · 0 comments

Comments

@alexsosa2000
Copy link

Summary of your issue

I'm trying to use DlibDotNet in a Blazor WebAssembly project and I'm getting DllNotFoundException: DlibDotNetNativeDnn. I think this may be because DlibDotNet doesn't have a wasm build.

I'm basically getting an image from the user, detecting the face with Dlib, and drawing a rectangle. But when I call Dlib.GetFrontalFaceDetector(), it throws the exception.

The same code works in a console app running in the same machine.

Environment

Blazor WebAssembly (.NET)
DlibDotNet nuget package v19.21.0.20220724

Example code:

To repro:

  • Create a Blazor WebAssembly project
  • Add a package reference to DlibDotNet
  • Add the following code to a page / component:
using (var fd = Dlib.GetFrontalFaceDetector())
{
	var img = Dlib.LoadPng<RgbPixel>(imgArray);

	// find all faces in the image
	var faces = fd.Operator(img);

	return faces;
}
  • Launch in the browser so it executes this code
  • You'll see an error in the console (DevTools - F12)

Output:

Error: System.TypeInitializationException: The type initializer for 'DlibDotNet.NativeMethods' threw an exception.
 ---> System.DllNotFoundException: DlibDotNetNativeDnn
   at DlibDotNet.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at DlibDotNet.Dlib.GetFrontalFaceDetector()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant