The following code will display an image correctly using cv2 in python:
import cv2
img = 'image file.jpg'
frame = cv2.imread(img)
while True:
cv2.imshow('frame', frame)
if cv2.waitKey(20) == ord('q'):
break
However, say I want to run a for loop which incorporates cv2 showing an image:
import cv2
img = 'image file.jpg'
frame = cv2.imread(img)
test = [1,2]
for t in test:
print(t)
cv2.imshow('frame', frame)
if cv2.waitKey(20) == ord('q'):
break
I expected this code to show the image twice, but the image isn't shown at all. 't' is printed correctly. What am I missing?