Esempio n. 1
0
def capture_frame():
    sender = FaceSender()
    capture = cv2.VideoCapture(-1)

    while True:
        _, frame = capture.read()
        cv2.imshow('Ringo Capture', frame)

        key = 0xFF & cv2.waitKey(10)

        if key == 13 or key == 10:  # Enter
            gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            faces = detect_face(gray_frame)

            if faces.size > 0:
                # If we have a face, send the picture and wait for the reply which
                # contains the URL assigned to the picture.
                picture = sender.post_picture(frame_to_png(frame), 'png')

                # Append each rect to the list along with the picture URL obtained
                # before
                rects = []
                for (x, y, w, h) in faces:
                    cv2.rectangle(frame, (x, y), (x+w, y+h), GREEN, 1)
                    rects.append(get_rect(x, y, w, h, picture))

                # Send the rects
                sender.post_rect(rects)
                sender.close()

                cv2.imshow('Face', frame)

        elif key == 27:  # Escape
            break
Esempio n. 2
0
while True:
    _, frame = capture.read()

    cv2.imshow('Ringo Capture', frame)

    key = 0xFF & cv2.waitKey(10)

    if key == 13 or key == 10:  # Enter
        gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        faces = detect_face(gray_frame)

        if faces.size > 0:
            # If we have a face, send the picture and wait for the reply which
            # contains the URL assigned to the picture.
            picture = sender.post_picture(frame_to_png(frame), 'png')

            # Append each rect to the list along with the picture URL obtained
            # before
            rects = []
            for (x, y, w, h) in faces:
                cv2.rectangle(frame, (x, y), (x + w, y + h), GREEN, 1)
                rects.append(get_rect(x, y, w, h, picture))

            # Send the rects
            sender.post_rect(rects)
            sender.close()

            cv2.imshow('Face', frame)

    elif key == 27:  # Escape
Esempio n. 3
0
while True:
    _, frame = capture.read()

    cv2.imshow('Ringo Capture', frame)

    key = 0xFF & cv2.waitKey(10)

    if key == 13 or key == 10:  # Enter
        gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        faces = detect_face(gray_frame)

        if faces.size > 0:
            # If we have a face, send the picture and wait for the reply which
            # contains the URL assigned to the picture.
            picture = sender.post_picture(frame_to_png(frame), 'png')

            # Append each rect to the list along with the picture URL obtained
            # before
            rects = []
            for (x, y, w, h) in faces:
                cv2.rectangle(frame, (x, y), (x+w, y+h), GREEN, 1)
                rects.append(get_rect(x, y, w, h, picture))

            # Send the rects
            sender.post_rect(rects)
            sender.close()

            cv2.imshow('Face', frame)

    elif key == 27:  # Escape
Esempio n. 4
0
while True:
    _, frame = capture.read()

    cv2.imshow("Ringo Capture", frame)

    key = 0xFF & cv2.waitKey(10)

    if key == 13 or key == 10:  # Enter
        gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        faces = detect_face(gray_frame)

        if faces.size > 0:
            # If we have a face, send the picture and wait for the reply which
            # contains the URL assigned to the picture.
            picture = sender.post_picture(frame_to_png(frame), "png")

            # Append each rect to the list along with the picture URL obtained
            # before
            rects = []
            for (x, y, w, h) in faces:
                cv2.rectangle(frame, (x, y), (x + w, y + h), GREEN, 1)
                rects.append(get_rect(x, y, w, h, picture))

            # Send the rects
            sender.post_rect(rects)
            sender.close()

            cv2.imshow("Face", frame)

    elif key == 27:  # Escape