示例#1
0
文件: test.py 项目: MrTurtleW/code
def test_camera():
    video_capture = cv2.VideoCapture(0)
    pnet = PNet()
    rnet = RNet()
    onet = ONet()

    frame_counter = 0
    boxes, landmarks = None, None

    while True:
        ret, frame = video_capture.read()
        if ret:
            if frame_counter % 10 == 0:
                boxes = pnet.detect(frame)
                if len(boxes) > 0:
                    boxes = rnet.detect(frame, boxes)
                    if len(boxes) > 0:
                        boxes, landmarks = onet.detect(frame, boxes)
                    else:
                        boxes, landmarks = None, None

        if boxes is not None:
            draw(frame, boxes, landmarks)
        cv2.imshow('image', frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

        frame_counter += 1
示例#2
0
文件: test.py 项目: MrTurtleW/code
def test_img():
    pnet = PNet()
    rnet = RNet()
    onet = ONet()
    img = cv2.imread('C:\\Users\\lenovo\\Desktop\\0_Parade_Parade_0_693.jpg')
    boxes = pnet.detect(img)

    boxes = rnet.detect(img, boxes)
    boxes, landmarks = onet.detect(img, boxes)
    draw(img, boxes, landmarks)
    cv2.imshow('image', img)
    cv2.waitKey()