Beispiel #1
0
webcam = Webcam()
#webcam.start()


def draw(img, corners, imgpts):
    corner = tuple(corners[0].ravel())
    img = cv2.line(img, corner, tuple(imgpts[0].ravel()), (255, 0, 0), 5)
    img = cv2.line(img, corner, tuple(imgpts[1].ravel()), (0, 255, 0), 5)
    img = cv2.line(img, corner, tuple(imgpts[2].ravel()), (0, 0, 255), 5)
    return img


while True:

    # get image from webcam
    webcam.update_frame()
    image = webcam.get_current_frame()

    criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
    objp = np.zeros((3 * 5, 3), np.float32)
    objp[:, :2] = np.mgrid[0:5, 0:3].T.reshape(-1, 2)
    objpoints = []  # 3d point in real world space
    imgpoints = []
    axis = np.float32([[3, 0, 0], [0, 3, 0], [0, 0, -3]]).reshape(-1, 3)

    # save image to file, if pattern found
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    ret, corners = cv2.findChessboardCorners(gray, (5, 3), None)

    if True:
        print(