accord-net / framework

Machine learning, computer vision, statistics and general scientific computing for .NET
http://accord-framework.net
GNU Lesser General Public License v2.1
4.5k stars 1.99k forks source link

Using Accord.net with Unity3d(windows) error #874

Open AbhimanyuAryan opened 7 years ago

AbhimanyuAryan commented 7 years ago

Hi, I'm following this blog post.

But when I play my scene in Unity. Unity throws an error

TypeLoadException: Could not load type ‘Accord.DirectSound.AudioDeviceInfo’ from assembly ‘Accord.Audio.DirectSound, Version=3.3.0.0, Culture=neutral.

I'm using Unity2017.1 @unitycoder have you found a solution?

unitycoder commented 7 years ago

for temporary fix can delete the Accord.Audio.DirectSound.dll..

in 2017 with 4.6 enabled is says, this so not sure if some problem with that file? "Unloading broken assembly Assets/Plugins/Accord.Audio.DirectSound.dll, this assembly can cause crashes in the runtime"

cesarsouza commented 7 years ago

Hi everyone,

@AbhimanyuAryan, many thanks for opening the issue! Please, may I ask which Accord.NET assemblies do you need to load in Unity? If your application does not need audio support, you can safely remove the references to any of the Accord.Audio assemblies from your project.

Regards, Cesar

AbhimanyuAryan commented 7 years ago

net35. So, if I'm not using Audio Support then let them be there? @cesarsouza

cesarsouza commented 7 years ago

You can remove them if you want. If you are not using audio, you can remove all the .Audio assemblies, such as Accord.Audio, Accord.Audio.DirectSound, Accord.Audition, etc. In the same way, if you are not using video, you can also remove all the Accord.Video assemblies such as Accord.Video, Accord.Video.FFMPEG, Accord.Video.DirectShow, etc.

cesarsouza commented 7 years ago

The latest pre-release version of the framework can now be installed in Unity projects through NuGet. A preliminary guide on how to install the Accord.NET Framework on Unity through NuGet is now available here.

It is not perfect, though. There are a few steps which might have to be documented better. If anyone finds a problem while following them, please feel free to update this issue or open a new one here in the issue tracker!

cesarsouza commented 7 years ago

I've just updated the tutorial with a series with a series of screenshots. Hope it will be easier to follow now!

AbhimanyuAryan commented 7 years ago

@cesarsouza can you include instructions on Visual Studio Code instead of Visual Studio? Also, use Nuget CLI commands. With that, you can actually help MacOS users as well 💯

Plz, use the command line. Say restore packages with dotnet restore & stuff like that

Here are some links: https://docs.microsoft.com/en-us/dotnet/core/tools/project-json-to-csproj

I know how to deal with packages in project.json based project but no idea with .csproj based projects. Can you help out here a bit?

cesarsouza commented 7 years ago

Hi @AbhimanyuAryan,

Thanks for the suggestion. To tell the truth, I do not know much about VS code or the project.json project format (wasn't it deprecated in favor of .csproj?).

Another complicating factor is that the Unity editor actually performs a bunch of magic when interacting with VS. Since I do not own a Mac, I do not know how it interacts with VS code under OS X. So if you do not mind, I might need a bit of help from you as well to write a tutorial for Mac OS X users 😄

Have you been able to follow the tutorial up to a certain point? If you are stuck the part where I had switched to VS to download and install the framework's NuGet packages, I guess you can achieve the same using

dotnet add package Accord.MachineLearning --version 3.7.2-alpha

Please let me know if it works for you!

Regards, Cesar

AbhimanyuAryan commented 7 years ago

I had already tried that

screen shot 2017-09-24 at 5 19 21 am

cesarsouza commented 7 years ago

Hi @AbhimanyuAryan,

From your screenshot I can see there are indeed two .csproj files in your solution folder. Have you tried to do as the error message says and specify which one should be used? I guess this should be done using

dotnet add Snapchat.csproj Accord.MachineLearning --version 3.7.2-alpha

or

dotnet add Assembly-CSharp-(rest of the proj filename that is not completely visible in the screenshot).csproj Accord.MachineLearning --version 3.7.2-alpha

Hopefully one of those should work!

Regards, Cesar

AbhimanyuAryan commented 7 years ago
❯ dotnet add Snapchat.csproj Accord.MachineLearning --version 3.7.2-alpha
Specify --help for a list of available options and commands.
Unrecognized command or argument 'Accord.MachineLearning'
cesarsouza commented 7 years ago

I think it's

dotnet add Snapchat.csproj package Accord.MachineLearning --version 3.7.2-alpha

or

dotnet add package Accord.MachineLearning Snapchat.csproj --version 3.7.2-alpha
AbhimanyuAryan commented 7 years ago
❯ dotnet add Snapchat.csproj package Accord.MachineLearning --version 3.7.2-alpha

Microsoft (R) Build Engine version 15.1.548.43366
Copyright (C) Microsoft Corporation. All rights reserved.

  Writing /var/folders/5n/ghyfb6n9387_h2w5ycg9pd980000gn/T/tmp6NzYmT.tmp
info : Adding PackageReference for package 'Accord.MachineLearning' into project 'Snapchat.csproj'.
error: Value cannot be null.
error: Parameter name: projectUniqueName
cesarsouza commented 7 years ago

I've also tried installing them through VS developer command prompt, but nothing works. I do not get the same error as you though, I get something similar to https://github.com/NuGet/Home/issues/5454.

Have you tried installing the packages manually (as shown in the first part of the guide)?

Regards, Cesar