private void AddDetectedFacesToListViewPanel() { try { if (its_time_to_pick_perpetrator_faces) { if (detected_faces != null && current_frame != null) { ImageListView image_list_view = Singleton.SELECT_PERP_FACES.GetImageListView(); for (int i = 0; i < detected_faces.Length; i++) { //get face Image <Bgr, byte> face = FramesManager.CropSelectedFace(detected_faces[i], current_frame.Clone()); //resize face face = FramesManager.ResizeColoredImage(face, new Size(120, 120)); //add face to image list Singleton.SELECT_PERP_FACES.suspect_faces.TryAdd(count, face); //add face to image list view image_list_view.Invoke(new AddImage(Singleton.SELECT_PERP_FACES.AddImage), new object[] { "face " + count, "face " + count, face.ToBitmap() }); //increment id counter count++; } } } } catch (Exception e) { Debug.WriteLine(e.Message); } }
//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); } }