I am a unity developer trying my hands on opencv for the first time. My initial goal is to run the camera and detect blobs via opencv in unity3d. I am new to OpenCV and am trying to integrate it in Unity3D (on Windows 8 with Unity 4.3.2 and on a mac with Unity 4.2.1f). I followed this thread. But I am getting the following error as soon as I add a new C# script. And the moment I delete this script, the error goes (this script is Unity generated C# script).
Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
I couldn't find much about Unity and OpenCV integration. It would be great if you could help me out with this error and point me to a recent tutorial to learn more.
Thanks in advance!
We recently had to deal with the same problem, I'll post some generic information that would solve your problem and help other people.
To use your OpenCV project inside a C# script, follow this code example:
using UnityEngine;
using System.Collections;
using System;
using System.Runtime.InteropServices;
public class PluginImport : MonoBehaviour {
//Lets make our calls from the Plugin
[DllImport ("OpenCVProject")]
private static extern int openCVFunction();
void Start () {
openCVFunction();
}
}
pay attention to the using
directives!
Other sources of information:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With