python - Layout of the output array img is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels) -
i error: layout of output array img incompatible cv::mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels) when running following code:
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 m in matches: # draw 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)
this code getting corresponding features in 2 similar images different views. please ??
change line:
img = np.hstack((i1, i2))
to:
img = np.array(np.hstack((i1, i2)))
Comments
Post a Comment