Ejemplo n.º 1
0
 public void FramesManagerCropSelectedFaceTest()
 {
     Rectangle[] faces = FramesManager.DetectFacesInFrame(Singleton.FACE_PIC, Singleton.HAARCASCADE);
     //Image<Bgr, byte> image = Singleton.FACE_PIC.Clone();
     //Image<Bgr,byte> image_result=FramesManager.CropSelectedFace(faces[0], Singleton.FACE_PIC);
     //Assert.IsNotNull(image_result);
 }
        //DETECTS FACES IN THE CURRENT FRAME
        public bool DetectFacesInFrame()
        {
            //try to get a frame from the shared datastore for captured frames
            sucessfull = Singleton.REVIEW_FRAMES_TO_BE_PROCESSED.TryDequeue(out current_frame);


            //if ok
            if (sucessfull)
            {
                //detect faces in frame
                detected_faces = FramesManager.DetectFacesInFrame(current_frame.Clone(), haarcascade);
                return(true);
            }
            //IF NO FRAMES IN DATA STORE
            else
            {
                //IF OUTPUT GRABBER THREAD IS DONE THEN IT MEANS THE FRAMES ARE DONE
                //TERMINATE THIS THREAD AND SIGNAL TO OTHERS THAT IT IS DONE
                if (VideoFromFileThread.WORK_DONE)
                {
                    WORK_DONE = true;
                    running   = false;
                }
                return(false);
            }
        }
Ejemplo n.º 3
0
        public void FramesManagerDetectFacesInFrameTest()
        {
            Rectangle[] faces = FramesManager.DetectFacesInFrame(Singleton.FACE_PIC, Singleton.HAARCASCADE);

            //THE METHOD MUST DETECT A FACE IN THE PROVIDED PIC
            Assert.IsTrue(faces.Length >= 1);
        }
Ejemplo n.º 4
0
        public void FramesManagerDrawShapeAroundDetectedFacesTest()
        {
            Rectangle[] faces = FramesManager.DetectFacesInFrame(Singleton.FACE_PIC, Singleton.HAARCASCADE);
            bool        sucess;

            FramesManager.DrawShapeAroundDetectedFaces(faces[0], Singleton.FACE_PIC, out sucess);
            Assert.IsTrue(sucess);
        }
Ejemplo n.º 5
0
        public void FaceDrawingThreadAddImageToQueueForDisplayTest()
        {
            HaarCascade haarcascade = Singleton.HAARCASCADE;

            Rectangle[]       faces  = FramesManager.DetectFacesInFrame(Singleton.FACE_PIC, haarcascade);
            FaceDrawingThread thread = new FaceDrawingThread(Singleton.FACE_PIC, faces, 1, 0);
            bool sucess = thread.AddImageToQueueForDisplay();

            Assert.IsTrue(sucess);
        }
Ejemplo n.º 6
0
        public void FaceDrawingThreadFaceDrawingThreadTest()
        {
            Image <Bgr, byte> frame       = Singleton.FACE_PIC;
            HaarCascade       haarcascade = Singleton.HAARCASCADE;

            Rectangle[]       faces  = FramesManager.DetectFacesInFrame(frame, haarcascade);
            FaceDrawingThread thread = new FaceDrawingThread(frame, faces, 1, 0);

            Assert.IsNotNull(thread);
        }
Ejemplo n.º 7
0
        public void FaceDrawingThreadDoWorkTest()
        {
            Image <Bgr, byte> frame       = Singleton.FACE_PIC;
            HaarCascade       haarcascade = Singleton.HAARCASCADE;

            Rectangle[]       faces  = FramesManager.DetectFacesInFrame(frame, haarcascade);
            FaceDrawingThread thread = new FaceDrawingThread(frame, faces, 1, 0);

            thread.StartWorking();
            Assert.IsTrue(thread.IsRunning());
            thread.RequestStop();
        }
Ejemplo n.º 8
0
        //DETECTS FACES IN THE CURRENT FRAME
        public bool DetectFacesInFrame()
        {
            try
            {
                //try to get a frame from the shared datastore for captured frames
                bool sucessfull = Singleton.LIVE_FRAMES_TO_BE_PROCESSED.TryDequeue(out current_frame);


                //if ok
                if (sucessfull)
                {
                    //detect faces in frame
                    detected_faces = FramesManager.DetectFacesInFrame(current_frame.Clone(), haarcascade);

                    if (detected_faces != null)
                    {
                        //for each face we have detected in the frame
                        foreach (var detected_face in detected_faces)
                        {
                            //get the face
                            Image <Bgr, byte> face = FramesManager.CropSelectedFace(detected_face, current_frame.Clone());

                            //add face to shared datastore so face recog thread can access it
                            Singleton.FACES_TO_RECOGNIZE.Enqueue(face);
                        }
                        detected_faces = null;
                    }
                    return(true);
                }

                //IF NO FRAMES IN DATA STORE THEN CHECK SUPPLIER THREAD FOR LIFE
                else
                {
                    CheckForTerminationOfThisThread();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }