- Home /
Unity/Kinect with Infer.net
Hello,
I'm working on a project using Unity with Microsoft Kinect (using OpenNI/NITE) and Microsoft infer .net machine learning tool to create some body gesture recognition using Kinect. I used the sample project with NITE as a start for unity and it works fine. The problem is when I tried to add the Infer .net dlls.
I am using Unity 3.2 pro. I copied all the dlls from the infer.net folder to the assets folder in my project. it first complained about some dlls from system (I don't know why ?) so I copied them to the assets as well (System.deplyment.dll , system.windows.forms.dll).
Finally the compiler was ok with all the classes and types. I compile in VS2010 and everything is ok. but when I play the program in Unity it gives me this error :
InvalidProgramException: Errors found when compiling algorithm:
MicrosoftResearch.Infer.ModelCompiler.CompileWithoutParams (ITypeDeclaration itd, System.Reflection.MethodBase method, MicrosoftResearch.Transforms.AttributeRegistry`2 inputAttributes)
and the log is
platform assembly: C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0\Mono.Security.dll (this message is harmless)
Platform assembly: C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0\System.Runtime.Serialization.Formatters.Soap.dll (this message is harmless)
Platform assembly: C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0\Mono.Posix.dll (this message is harmless)
Platform assembly: C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0\Microsoft.JScript.dll (this message is harmless)
Compilation failed with 3 error(s)(0,0) : error CS0006: cannot find metadata file `data-0AF40020'
(0,0) : error CS0006: cannot find metadata file `data-18E90020'
(0,0) : error CS0006: cannot find metadata file `data-12CB0020'
InvalidProgramException: Errors found when compiling algorithm:
at MicrosoftResearch.Infer.ModelCompiler.CompileWithoutParams (ITypeDeclaration itd, System.Reflection.MethodBase method, MicrosoftResearch.Transforms.AttributeRegistry`2 inputAttributes) [0x00000] in <filename unknown>:0 at MicrosoftResearch.Infer.InferenceEngine.Compile () [0x00000] in <filename unknown>:0 at MicrosoftResearch.Infer.InferenceEngine.BuildAndCompile (Boolean inferOnlySpecifiedVars, IEnumerable`1 vars) [0x00000] in <filename unknown>:0 at MicrosoftResearch.Infer.InferenceEngine.GetCompiledInferenceAlgorithm (Boolean inferOnlySpecifiedVars, IVariable var) [0x00000] in <filename unknown>:0 at MicrosoftResearch.Infer.InferenceEngine.InferAll (Boolean inferOnlySpecifiedVars, IVariable var) [0x00000] in <filename unknown>:0 at MicrosoftResearch.Infer.InferenceEngine.Infer[VectorGaussian] (IVariable var) [0x00000] in <filename unknown>:0 at BPM.InferW (System.Collections.Generic.List`1[] xValuesData) [0x0005e] in G:\study\kinect project\Unity kinect\Assets\scripts\BPM.cs:252 at BPM.Train (System.Collections.Generic.List`1[] xValuesData) [0x00069] in G:\study\kinect project\Unity kinect\Assets\scripts\BPM.cs:231 at BPMtest.Test_BPM (Int32 nClass, Int32 totalFeatures, Double noisePrec, System.String fileName, MicrosoftResearch.Infer.Maths.Vector[] testData) [0x00048] in G:\study\kinect project\Unity kinect\Assets\scripts\BPMtest.cs:58 at BPMtest.Start () [0x000c1] in G:\study\kinect project\Unity kinect\Assets\scripts\BPMtest.cs:38
Any Ideas ?
I'm sorry .. there seemed to be a problem with my internet connection. Everytime I was posting the question the respond was "sorry internal error." So I was trying again and didn't notice it was already posted. Sorry again :)
Answer by Dreamora · Jun 24, 2011 at 10:49 PM
The error unhappily does not say much as such. You won't be able to avoid to ask on the infer related pages (after checking its docs) on why it would fire that exception ie what could lead there.
Once you know that we can likely point you to the root on the unity side that lead there
this is the Error is was showing me before :
-----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/07d54f8f8fbca08489dbb7a783d5378c.dll
The following assembly referenced from G:\study\kinect project\Unity kinect\Assets\Infer\Infer.Runtime.dll could not be loaded:
Assembly: System.Windows.Forms (assemblyref_index=2)
Version: 2.0.0.0
Public $$anonymous$$ey: b77a5c561934e089
The assembly was not found in the Global Assembly Cache, a path listed in the $$anonymous$$ONO_PATH environment variable, or in the location of the executing assembly (G:\study\kinect project\Unity kinect\Assets\Infer).
so I just copied the "System.Windows.Forms" from the .net directory to the unity assets. Does this mean that it have some kind of different .net versions or something. I think this is what is making the error cz it shouldn't be like that ?!
Answer by Dreamora · Jun 25, 2011 at 12:27 AM
Oh I missed that part that you really copied the Windows.Forms.
You can't use Windows.forms with Unity at all and as such also no library that has a relationship to it. Not only is this library you copied for MS.NET and not even mono, but also it has various deep system dependencies which won't work out with unity.
Question is also why you need it cause Windows Forms is for the Windowing system etc, thats not a "just to be used" assembly aspect, which would imply that one of the libraries or an aspect of it is meant to show windows or dialogs. perhaps there is a library to "just use"?
ok .. After trying many things. I removed everything from the assets and just copied the dlls from the infer .net release folder. The compiler didn't complain about the missing windows.forms lib anymore. But when I run the same old error still shows up.
InvalidProgramException: Errors found when compiling algorithm
But in the log now there is only 1 missing metadata file is$$anonymous$$d of 3 before. So we made some progress :) .
Compilation failed with 1 error(s) (0,0) : error CS0006: cannot find metadata file `data-07200020'
Any Idea what this could be. could it be a version problem with .Net dlls. I need any help possible. Because if this doesn't work I have to move to use something else with unity.
I've no idea where this one comes from but I would guess from the infer compilation step and then it gets placed at the wrong place or is not included in the build at all. you might want to check where the compiled data files from infer are expected to be found and move them there manually for testing, if that works you can later on automate the step through a build post process script
seems exactly just like you said :) .. I tried some work around and it worked. Thank you very much .. i wouldn't have found it without you . I will try to post my last solution if everything will work out.
Glad it helped :)
Looking forward to what you create with it :)
ok I can see the problem now. infer generates a source code file first then compiles it to build it's algorithm. Now the problem is that infer is creating it's source code file outside the assets folder on the project root (the infer documentation says in "bin\\debug" folder. So maybe unity can't access that file after since it's not in it's assets folder and it stops infer from using it. $$anonymous$$y question is: Is there a way to change the working or maybe execution (I don't know what that is called) directory of unity project to be inside the assets folder? I don't think there is way to change that from infer's side.