Layout of the output array img is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)
14,124
change this line:
img = np.hstack((I1, I2))
to:
img = np.array(np.hstack((I1, I2)))
Author by
Fadi Makram
Updated on June 13, 2022Comments
-
Fadi Makram almost 2 years
I get this error: Layout of the output array img is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels) when running the 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 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)
This code is for getting corresponding features in two similar images from different views. Any help please ??