Пример #1
0
 void OnApplicationQuit()
 {
     if (_ready)
     {
         SocketsInterop.Close();
     }
 }
Пример #2
0
    void ThreadedWork()
    {
        _threadRunning = true;
        bool workDone = false;

        CvCircle[] _faces;


        int result = SocketsInterop.Init();

        if (result < 0)
        {
            if (result == -1)
            {
                Debug.LogWarningFormat("[{0}] Failed to find cascades definition.", GetType());
            }
            else if (result == -2)
            {
                Debug.LogWarningFormat("[{0}] Failed to open camera stream.", GetType());
            }

            return;
        }


        _faces = new CvCircle[2];
        NormalizedFacePositions = new List <Vector3>();
        _ready = true;

        // This pattern lets us interrupt the work at a safe point if neeeded.
        while (_threadRunning && !workDone)
        {
            if (!_ready)
            {
                return;
            }

            unsafe
            {
                fixed(CvCircle *outFaces = _faces)
                {
                    SocketsInterop.RunServer(outFaces);
                }
            }

            theCircle.X      = _faces[0].X;
            theCircle.Y      = _faces[0].Y;
            theCircle.Radius = _faces[0].Radius;

            //NormalizedFacePosition = new Vector2(((float)(640 - _faces[0].X) * DetectionDownScale) / 640f, 1f - (((float)_faces[0].Y * DetectionDownScale) / 480f));
            NormalizedFacePosition = new Vector3(theCircle.X, theCircle.Y, theCircle.Radius);
        }
        _threadRunning = false;
    }