void OnApplicationQuit()
 {
     if (_ready)
     {
         OpenCVInterop.Close();
     }
 }
示例#2
0
    void Update()
    {
        // attempt to reinitialize if connection was lost last frame or is not present on start
        if (cameraState == CameraState.disconnected || lastError < 0)
        {
            bool initialized = Initialize();
            if (!initialized)
            {
                return;
            }
        }

        // this is the main call to the dll that does the face detection processing on an OpenCV frame
        // it returns the data needed to build output in Unity
        cvFrame = GetFaceDetectionResults();
        //Debug.LogFormat("from frame, x = {0}, y = {1}, bufferSize = {2}, memPtr = {3}, error = {4}", cvFrame.x, cvFrame.y, cvFrame.bufferSize, cvFrame.memPtr, cvFrame.error);

        // handle error cases returend by dll; i.e. disconnected usb device
        if (cvFrame.error < 0)
        {
            //Debug.LogFormat("RunFaceDetection returned error {0}", cvFrame.error);
            OpenCVInterop.Close();
            cameraState = CameraState.disconnected;
            lastError   = cvFrame.error; // so we know to reinitialize rather than run demo next frame
            return;
        }

        // create array, marshal data from pointer, output, then free the pointer
        byte[] bytes = new byte[cvFrame.bufferSize];
        Marshal.Copy(cvFrame.memPtr, bytes, 0, cvFrame.bufferSize);
        OutputFrame(cvFrame, bytes);
        OpenCVInterop.FreeMemory();
    }
示例#3
0
 void OnApplicationQuit()
 {
     if (cameraState == CameraState.connected)
     {
         OpenCVInterop.Close();
         Destroy(tex);
     }
 }
 void OnApplicationQuit()
 {
     if (_ready)
     {
         Debug.Log("sdfsdf");
         OpenCVInterop.Close();
     }
 }
示例#5
0
 void OnApplicationQuit()
 {
     if (_ready)
     {
         Debug.LogWarningFormat("before closing application", GetType());
         OpenCVInterop.Close();
         Debug.LogWarningFormat("before closing application", GetType());
     }
 }
示例#6
0
 private void OnApplicationQuit()
 {
     OpenCVInterop.Close();
 }