示例#1
0
        public override void DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Debug.WriteLine("Perp Recognition Thread Running");
            while (running)
            {
                if (!paused)
                {
                    Image <Bgr, byte> face_to_recognize;


                    //TRY DEQUEUEING A FACE TO RECOGNIZE FROM SHARED DATASTORE
                    bool sucessfull = Singleton.FACES_TO_RECOGNIZE.TryDequeue(out face_to_recognize);

                    //IF DEQUEUE IS OK
                    if (sucessfull)
                    {
                        //IF THE ACTIVE PERPETRATORS HAVE CHANGED
                        if (enroll_again)
                        {
                            //CLEAR ALREADY ENROLLED FACES
                            faces_manager.ClearEnrolledFaces();

                            //GET THE LATEST ACTIVE PERPS
                            active_perpetrators = Singleton.ACTIVE_PERPETRATORS;

                            //ENROLL FACES OF THE PERPS
                            EnrollFacesToBeComparedAgainst();
                        }

                        //TRY TO RECOGNIZE THE FACE
                        RecognizeFace(face_to_recognize);
                    }

                    //IF NO FACE RETURNED THEN CHECK SUPPLIER THREADS FOR LIFE
                    else
                    {
                        //IF BOTH HAVE TERMINATED THEN TERMINATE THIS ONE ALSO
                        if (CameraOutputGrabberThread.WORK_DONE && LiveStreamFaceDetectingThread.WORK_DONE)
                        {
                            running   = false;
                            WORK_DONE = true;
                        }
                    }
                }
                Thread.Sleep(SLEEP_TIME);
            }
            CleanUp();
        }
 private void CleanUp()
 {
     WORK_DONE = true;
     faces_manager.ClearEnrolledFaces();
     faces_manager = null;
 }