I ran into the problem of having to create an arbitrary number of openCV windows. I saved them in a list and could not just loop it to display them:
# images is a list of openCV image object for img in images: cv2.imshow('image',i)
This does not work for a trivial reason when images require a different label, so this loop will only display the last item in the list.
This can be solved using the iterator and Python string formatting tools:
for i, img in enumerator(images): cv2.imshow("Image number {}".format(i), img)
Therefore, now all images will be displayed because they have been assigned a different label.
source share