1

我正在尝试使用cv2.estimateAffine3D()from (opencv 2.4.2) 函数来估计到 3D 点集之间的仿射 3D 变换。

这是我的代码:

def computeAffine3d():
    # Init src and dst points to 0 
    src_points = cv2.cv.CreateMat(1, 4, cv2.cv.CV_32FC3)
    dst_points = cv2.cv.CreateMat(1, 4, cv2.cv.CV_32FC3)
    cv2.cv.Zero(src_points)
    cv2.cv.Zero(dst_points)

    # Convert cv Mat to numpy array
    src_points = np.array( src_points )
    dst_points = np.array( dst_points )

    # Set src_points to (0,0,0), (1,0,0), (0,1,0) and (0,0,1)
    # Set dst_points to (1,0,0), (2,0,0), (1,1,0) and (1,0,1) 
    src_points[0][1][0] = 1.0
    src_points[0][2][1] = 1.0
    src_points[0][3][2] = 1.0 
    dst_points[0][0][0] = 1.0
    dst_points[0][1][0] = 2.0
    dst_points[0][2][0] = 1.0
    dst_points[0][2][1] = 1.0
    dst_points[0][3][0] = 1.0
    dst_points[0][3][2] = 1.0

    # Compute Affine 3D tranformation
    ok_flag, H, status1 = cv2.estimateAffine3D(src_points, dst_points)
    print ok_flag, ', ', H, ', ', status1

执行这段代码后,我收到以下错误:

cOpenCV Error: Assertion failed (CV_ARE_SIZES_EQ(m1, m2) && CV_ARE_SIZES_EQ(m1, mask)) in runRANSAC, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-0precise-20120908-1632/modules/calib3d/src/modelest.cpp, line 122
Traceback (most recent call last):
  File "./test_affine_estimation.py", line 33, in <module>
    computeAffine3d()
  File "./test_affine_estimation.py", line 25, in computeAffine3d
    ok_flag, H, status1 = cv2.estimateAffine3D(src_points, dst_points)
cv2.error: /tmp/buildd/ros-fuerte-opencv2-2.4.2-0precise-20120908-1632/modules/calib3d/src/modelest.cpp:122: error: (-215) CV_ARE_SIZES_EQ(m1, m2) && CV_ARE_SIZES_EQ(m1, mask) in function runRANSAC

任何想法?谢谢!

4

0 回答 0