Exemplo n.º 1
0
    def main(self):
                
        while(not self._event_quit):
            self.timer.mark_new_frame()

            #Capture frame-by-frame
            a_frame = self.capturer.get_frame()
            a_frame = flip_frame(a_frame)
            self.gui.feed_frame(a_frame)

            #detect face part:
            if self.should_process_this_frame:
                #face>>(x,y,w,h)
                face = self.detect_face_in_frame(a_frame)

                if face is not None:
                    self.gui.show_face_position(face)
                    if self._event_debug:
                        self.gui.show_face(face)
                    if self._event_auto_limit:
                        self._event_msg = self.handle_auto_limit(face)
                    elif self._event_enforcing:
                        self._event_msg = self.handle_enforce(face)

            #this if is out of the process one to leave the msg in between frames
            if self._event_msg:
                self.gui.show_msg(self._event_msg)

            #Check user input, this part needs to be after the frame has been created and fed to gui:
            self.dispatch_keyb_events()
            if self._event_debug:
                self.gui.show_debug(self.timer)
            #TODO: if face detected, work counter counts:
            if self.work_timer.is_started:
                self.gui.show_contdown(self.work_timer.get_time_left())
                
            #Add on-screen controls and limits visual guide:
            self.gui.show_controls()
            self.gui.show_limits(self.face_enforcer)

            #Display the resulting frame
            if self._event_image_show:
                self.gui.show_image()

        #if we are out of the while:
        self.clean_up()
Exemplo n.º 2
0
#FIXME quick and dirty counter for only processing every 5th frame.
fps_counter = 0
msg = None
debug = 'off'
#Main Loop
while(True):
    #Time tracking w opencv:
    timer.new_frame()

    fps_counter += 1

    #Capture frame-by-frame
    a_frame = capturer.get_frame()

    a_frame = flip_frame(a_frame)

    #display red line for lower limit
    #TODO: change this to a general method to show limits:
    gui.display_line(a_frame, (0, face_enforcer.y_limit_low),
                                (frame_width / 7, face_enforcer.y_limit_low), thickness=2)
    gui.display_line(a_frame, (frame_width - (frame_width / 7), face_enforcer.y_limit_low),
                                (1280, face_enforcer.y_limit_low), thickness=2)

    if fps_counter == 5:
        fps_counter = 0

        a_frame_prepared = convert_to_gray_and_equalize(a_frame)

        faces_list = face_classifier.detect_multiscale(a_frame_prepared)
Exemplo n.º 3
0
 def prepare_frame():
     frame = capturer.get_frame()
     if frame is not None:
         frame = flip_frame(frame)
         return convert_to_gray(frame)