So i was trying out the vconcat and hconcat funktion of OpenCv2 but whenever i run it, it gives me this error.
cv2.error: OpenCV(4.6.0) /io/opencv/modules/core/src/matrix_operations.cpp:65: error: (-215:Assertion failed) src[i].dims <= 2 && src[i].rows == src[0].rows && src[i].type() == src[0].type() in function 'hconcat
here is the code:
import cv2
img1 = cv2.imread('test1.jpeg')
img2 = cv2.imread('book.jpg')
h_concat_img = cv2.hconcat([img1, img2])
v_concat_img = cv2.vconcat([img1, img2])
cv2.imshow('horizontal', h_concat_img)
cv2.imshow('vertical', v_concat_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
And i think its only a problem from my site.
Python 3.10.8 Opencv 4.6.0
I was very confused even tried copying "Exactly" what a website told me with the same file name, here is the code
CodePudding user response:
From docs for hconcat
:
All of the matrices must have the same number of rows and the same depth.
Same for vconcat
:
All of the matrices must have the same number of cols and the same depth.
Examine img1.shape
and img2.shape
. If you still need help, please share your images in your question.