我收到此错误:运行以下代码时,输出数组 img 的布局与 cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels) 不兼容:
I1 = cv2.imread('library1.jpg');
I2 = cv2.imread('library2.jpg');
# Load matching points
matches = np.loadtxt('library_matches.txt');
img = np.hstack((I1, I2))
# Plot corresponding points
radius = 2
thickness = 2
for m in matches:
# draw the keypoints
pt1 = (int(m[0]), int(m[1]))
pt2 = (int(m[2] + I1.shape[1]), int(m[3]))
lineColor = cv2.cv.CV_RGB(255, 0, 0)
ptColor = cv2.cv.CV_RGB(0, 255, 0)
cv2.circle(img, pt1, radius, ptColor, thickness)
cv2.line(img, pt1, pt2, lineColor, thickness)
cv2.circle(img, pt2, radius, ptColor, thickness)
cv2.imshow("Matches", img)
此代码用于从不同视图中获取两个相似图像中的相应特征。请问有什么帮助吗??