示例#1
0
    def show_max_window(self):
        while True:
            frame = self.tcp.frame.copy()
            face_detect_bool = self.face_detect_flag.get()
            face_save_bool = self.face_save_flag.get()

            # detect the face and label
            if face_detect_bool:
                self.face_detector.detect_face(frame)
                face_list = self.face_detector.get_face_list()
                if len(face_list) > 0:
                    for face in face_list:
                        Drawer.label_face(frame, face.get_rect())
                        # save face(s)
                        if face_save_bool is True:
                            self.save_face(self.tcp.frame, face.get_rect())
            else:
                if face_save_bool:
                    msg.showwarning(
                        "Warning",
                        "Open Face Detection before save face image!")
                    self.face_save_flag.set(False)

            # Write Text on the frame
            localtime = time.asctime(time.localtime(time.time()))
            width = frame.shape[0]
            cv2.putText(frame, localtime, (int(0.9 * width), 20),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.4, (0, 255, 0))
            if face_detect_bool is True:
                cv2.putText(frame, "Face Detection: True",
                            (int(0.9 * width), 35), cv2.FONT_HERSHEY_SIMPLEX,
                            0.4, (0, 255, 0))
            else:
                cv2.putText(frame, "Face Detection: False",
                            (int(0.9 * width), 35), cv2.FONT_HERSHEY_SIMPLEX,
                            0.4, (0, 0, 255))
            if face_save_bool is True:
                cv2.putText(frame, "Face Save     : True",
                            (int(0.9 * width), 50), cv2.FONT_HERSHEY_SIMPLEX,
                            0.4, (0, 255, 0))
            else:
                cv2.putText(frame, "Face Save     : False",
                            (int(0.9 * width), 50), cv2.FONT_HERSHEY_SIMPLEX,
                            0.4, (0, 0, 255))

            cv2.imshow("Split@Monitor %d" % (self.idx + 1), frame)
            if cv2.waitKey(1) == ord('q'):
                cv2.destroyAllWindows()
                break