コード例 #1
0
def main(args):
    code = wrnchAI.license_check_string(args.license_key) if args.license_key \
        else wrnchAI.license_check()

    if code != 0:
        raise RuntimeError(wrnchAI.returncode_describe(code))

    print('Initializing networks...')
    estimator = wrnchAI.PoseEstimator(models_path=args.models_dir,
                                      license_string=args.license_key)
    estimator.initialize_head(args.models_dir)
    print('Initialization done!')

    options = wrnchAI.PoseEstimatorOptions()
    options.estimate_heads = True
    options.estimate_face_poses = True

    print('Opening webcam...')
    with videocapture_context(args.webcam_index) as cap:
        visualizer = Visualizer()

        while True:
            _, frame = cap.read()

            if frame is not None:

                estimator.process_frame(frame, options)
                heads = estimator.heads()
                faces = estimator.faces()

                visualizer.draw_image(frame)
                for head in heads:
                    bounding_box = head.bounding_box
                    visualizer.draw_box(bounding_box.min_x, bounding_box.min_y,
                                        bounding_box.width,
                                        bounding_box.height)

                for face in faces:
                    landmarks = face.landmarks()
                    arrow = face.arrow()

                    visualizer.draw_points(landmarks, joint_size=2)
                    visualizer.draw_arrow(arrow)

                visualizer.show()

            key = cv2.waitKey(1)

            if key & 255 == 27:  # escape key
                break
コード例 #2
0
ファイル: head_sample.py プロジェクト: FynnSu/ImplementAI2019
visualizer = Visualizer()

while True:
    ret, frame = cap.read()

    if frame is not None:

        estimator.process_frame(frame, options)
        heads = estimator.heads()
        faces = estimator.faces()

        visualizer.draw_image(frame)
        for head in heads:
            bounding_box = head.bounding_box
            visualizer.draw_box(bounding_box.min_x, bounding_box.min_y,
                                bounding_box.width, bounding_box.height)

        for face in faces:
            landmarks = face.landmarks()
            arrow = face.arrow()

            visualizer.draw_points(landmarks, joint_size=2)
            visualizer.draw_arrow(arrow)

        visualizer.show()

    key = cv2.waitKey(1)

    if key & 255 == 27:  # escape key
        break
コード例 #3
0
    if frame is not None:

        estimator.process_frame(frame, options)

        visualizer.draw_image(frame)

        draw_hands(estimator.left_hands())
        draw_hands(estimator.right_hands())
        hand_box_pairs = estimator.hand_boxes()

        for hand_box_pair in hand_box_pairs:
            left_box = hand_box_pair.left
            right_box = hand_box_pair.right

            visualizer.draw_box(left_box.min_x, left_box.min_y,
                                left_box.width, left_box.height)
            visualizer.draw_box(right_box.min_x, right_box.min_y,
                                right_box.width, right_box.height)

        visualizer.show()

    key = cv2.waitKey(1)

    if key & 255 == 27:  # escape key
        break


cap.release()

cv2.destroyAllWindows()