python cv2.calibrateCamera throws error: objectPoints should contain vector of vectors of points of type Point3f

前端 未结 3 1170
忘了有多久
忘了有多久 2021-01-14 14:14

I have the code

img = cv2.imread(\"poolPictures\\chessboard3.jpg\", cv2.IMREAD_COLOR)
chessboardImage = cv2.imread(\"poolPictures\\chessboardActual.jpg\", c         


        
3条回答
  •  耶瑟儿~
    2021-01-14 14:53

    As Zenith042 pointed out, I had image points and object points the wrong way round. However, the main issue was that instead of a numpy array for my image points like:

    [[[ 137.5  205. ]]
    [[ 143.5  206.5]]
     .
     .
     .
    [[ 137.5  209.5]]]
    

    I instead needed:

    [[ 137.5 205. ]
    [ 143.5 206.5]
    .
    .
    .
    [ 137.5 209.5]]]
    

    Which I achieved with:

    ret, corners = cv2.findChessboardCorners(img, (9,6), None)
    corners = np.array([[corner for [corner] in corners]])
    

    although I suspect there is a nicer way with numpy.reshape.

    I also needed the same structure for the object points, i.e.

    objp = np.array([objp])
    

提交回复
热议问题