estimateAffine3D opencv 2.4 CV_ARE_SIZES_EQ(m1,m2)&& CV_ARE_SIZES_EQ(m1,掩码)

时间:2012-09-27 11:18:22

标签: python opencv

我正在尝试使用(opencv 2.4.2)函数中的cv2.estimateAffine3D()来估计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

有什么想法吗? 亲爱的!

0 个答案:

没有答案
相关问题