Python cv2 在一个请求中读取两个图像路径



嗨,Stackoverflow社区,有没有办法一次为cv2提供两个图像? 我正在使用Python 2.7,下面是我尝试的代码:

image1 = abc.jpg
image2 = def.jpg
imageArry = []
imageArry.append(image1,image2)
cv2.imread(imageArry)

这行不通,因为不正确,我的问题是,如果成功在一个数组中附加两个图像,在 cv2.imread 中它会一次获得两张图片吗?

我有一个解决方案,它可能能够在下面做到这一点:

image1 = abc.jpg
image2 = def.jpg
imageArry = []
for ix in [image1, image2]
imageArry.append(ix)
imageCatch = ','.join(imageArry)
getCatch1,getCatch2 = imageCatch.split(',')
if getCatch1 is not None:
img = cv2.imread(getCatch1)
elif getCatch2 is not None:
img =cv2.imread(getCatch2)

它可能看起来不太好,但目前没有错误,如果有人能让它变得更好,可以尝试谢谢。

最新更新