i want to extract 2 photo present in my directory using a for loop . in each iteration it will bring a photo. After getting both photos another if statement will trigger and will print "Both images extracted from directory successfully". This is the code ==>
import cv2
import os
import re
from skimage.io import imread,imshow,imsave
images =os.listdir('D:\programs python/regeneration\Mi3_Aligned/1')
img = None
ref_img = None
for i in images:
if i == "1.bmp":
img = imread('D:\programs python/regeneration\Mi3_Aligned/1/' + i)
img = cv2.resize(img, (980, 980), cv2.INTER_AREA)
if i == "2.bmp":
ref_img = imread('D:\programs python/regeneration\Mi3_Aligned/1/'+ i)
ref_img = cv2.resize(img, (980, 980), cv2.INTER_AREA)
if (img!=None and ref_img!=None):
print("Both images extracted from directory successfully")
But it is generating an error and i cannot understand what is the problem
if (img!=None and ref_img!=None):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Please Help!!!