I’m getting this error when running the below code:
PS C:UsersjsgesDownloads4-27-IMDbPy Files> python image_stitching.py
stitching ain’t successful
Traceback (most recent call last):
File “C:UsersjsgesDownloads4-27-IMDbPy Filesimage_stitching.py”, line 28, in
cv2.imshow(‘final result’,output)
cv2.error: OpenCV(4.10.0) D:aopencv-pythonopencv-pythonopencvmoduleshighguisrcwindow.cpp:973: error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow
Other posts indicate this is related to images not being in the folder or recognized, but they are in the same folder, and all the extensions and such are correct.
This is my code:
import cv2
image_paths=['imgt01.jpg','imgt02.jpg','imgt03.jpg']
# initialized a list of images
imgs = []
for i in range(len(image_paths)):
imgs.append(cv2.imread(image_paths[i]))
#imgs[i]=cv2.resize(imgs[i],(703,1042),fx=0.4,fy=0.4)
# showing the original pictures
cv2.imshow('imgt01.jpg',imgs[0])
cv2.imshow('imgt02.jpg',imgs[1])
cv2.imshow('imgt03.jpg',imgs[2])
stitchy=cv2.Stitcher.create()
(dummy,output)=stitchy.stitch(imgs)
if dummy != cv2.STITCHER_OK:
# checking if the stitching procedure is successful
# .stitch() function returns a true value if stitching is
# done successfully
print("stitching ain't successful")
else:
print('Your Panorama is ready!!!')
# final output
cv2.imshow('final result',output)
cv2.waitKey(0)
5