// Use this for initialization void Start() { MyDelegate callback_delegate = new MyDelegate(CallBackFunction); // Convert callback_delegate into a function pointer that can be // used in unmanaged code. IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(callback_delegate); // Call the API passing along the function pointer. OpenCVInterop.SetDebugFunction(intptr_delegate); OpenCVInterop.Test("Hello World!"); OpenCVInteropTest.Init("yolo-voc.cfg", "yolo-voc.weights", "data/voc.names", ""); OpenCVInterop.Open(0, 640, 480); tex = new Texture2D(640, 480, TextureFormat.RGB24, false); imgData = new byte[640 * 480 * 3]; colorData = new Color[640 * 480]; test = new int[4]; OpenCVInterop.TestArray(test); Debug.LogError("int list"); new List <int>(test).ForEach(x => Debug.LogError(x)); GetComponent <MeshRenderer>().material.mainTexture = tex; GetComponent <MeshRenderer>().material.SetTextureScale("_MainTex", new Vector2(-1, 1)); // flip texture horizontally, due to memcpy little endian //OpenCVInterop.Detect(imgData, "yolo-voc.cfg", "yolo-voc.weights", "data/voc.names", "camera", "", 0.200000003F, false); //Debug.LogError("data size: " + imgData.Length); //GCHandle handle = GCHandle.Alloc(imgData, GCHandleType.Pinned); //IntPtr ptr = handle.AddrOfPinnedObject(); //Marshal.Copy(imgData, 0, ptr, 640 * 480 * 3); //var incoming = new byte[1280 * 720 * 3]; //unsafe //{ // fixed (byte* inBuf = incoming) // { // byte* outBuf = OpenCVInterop.Detect("yolo-voc.cfg", "yolo-voc.weights", "data/voc.names", "camera", 1280, 720); // // Assume, that the same buffer is returned, only with data changed. // // Or by any other means, get the real length of output buffer (e.g. from library docs, etc). // for (int i = 0; i < incoming.Length; i++) // incoming[i] = outBuf[i]; // } //} }