The layout of the output img array is not compatible with cv :: Mat (step [ndims-1]! = Elemsize or step [1]! = Elemsize * nchannels)

I get this error: The layout of the output img array is not compatible 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 intended for receiving corresponding functions in two similar images from different representations. Any help please ??

+4
source share
1 answer

change this line:

img = np.hstack((I1, I2))

in

img = np.array(np.hstack((I1, I2)))

+2
source

Source: https://habr.com/ru/post/1479912/


All Articles