How to use opencv in Unity3d?
Check this link: OpenCV + Unity3D integration
Also there is Paid Plugin at unity Store: (it supports mobile platforms)
http://forum.unity3d.com/threads/released-opencv-for-unity.277080/
Link at the store
https://www.assetstore.unity3d.com/en/#!/content/21088
zakjma
Updated on August 23, 2020Comments
-
zakjma almost 4 years
I installed unity3D. I created a basic AR sample on it. I want to use opencv on unity3d. To do,there are some ways. I want to use opencvsharp. I install opencvsharp2.4.10 because I have installed opencv2.4.10.
I don't know next step? How I can integrate opencv with unity3d? I don't find heplful tutorial. I use 64bit and windows8.
EDIT
I learned that we can use c++ code(includes opencv function) in unity3d. I created dll using by visual stuio 2013. Guide link is here. Now I try to call
substract
function in unity.[DllImport ("MatFuncsDll")] private static extern double Subtract(double a, double b); void Update () { if (Input.GetMouseButtonDown (0)) { /*Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); float dist; plane.Raycast (ray, out dist); v3OrgMouse = ray.GetPoint (dist); v3OrgMouse.y = 0;*/ mTrackableBehaviour.gameObject.transform.position = new Vector3 ( mTrackableBehaviour.gameObject.transform.position.x + (float)Subtract (1, 0.5), mTrackableBehaviour.gameObject.transform.position.y, mTrackableBehaviour.gameObject.transform.position.z); } }
When I run this code I get
EntryPointNotFoundException:Substract
. I putMathFuncDll
underC://Program Fİles(x86)/Unity/Editor
and same directory Assets-Library under unity project. -
zakjma about 9 yearsI don't want to use extension from asset store due to not free. Thanks your help.
-
Mamdouh about 9 yearsFirst Link is not for an extension. its how to use OpenCV assemblies as a plugin inside unity. it benefits from Unity's ability to include code created outside Unity in the form of a Plugin.
-
zakjma about 9 yearsDo you know how to use dynamic library in unity? I want to use dynamic extension not static.
-
Mamdouh about 9 yearsusing DLL in unity can be in the form of a plugin as I mentioned earlier. here is another link might helps: stackoverflow.com/questions/15923595/… but regarding OpenCV Dynmic not static.. I am not quite sure because I didn't try it, and the guy in the prev link claims it must be static only... check the official documentation from unity regarding plugins hope it can be handy to you.