2

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 put MathFuncDll under C://Program Fİles(x86)/Unity/Editor and same directory Assets-Library under unity project.

zakjma
  • 2,030
  • 12
  • 40
  • 81
  • Check this thread: [opencv-emgucv-wrapper-integration-in-unity][1] [1]: http://stackoverflow.com/questions/16612513/opencv-emgucv-wrapper-integration-in-unity – Mamdouh Apr 20 '15 at 11:38
  • @dArKpRiNcE I don't want to use EmguCV. EmguCV free version is only supported desktop applications, not mobile apps. – zakjma Apr 20 '15 at 15:03

1 Answers1

2

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

Community
  • 1
  • 1
Mamdouh
  • 186
  • 2
  • 7
  • I don't want to use extension from asset store due to not free. Thanks your help. – zakjma Apr 21 '15 at 13:35
  • 1
    First 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. – Mamdouh Apr 21 '15 at 13:45
  • Do you know how to use dynamic library in unity? I want to use dynamic extension not static. – zakjma Apr 21 '15 at 15:27
  • using DLL in unity can be in the form of a plugin as I mentioned earlier. here is another link might helps: http://stackoverflow.com/questions/15923595/how-to-use-a-c-dll-in-unity3d 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. – Mamdouh Apr 23 '15 at 07:40