I have a folder with images which I read sequentially and save them to another folder, using a for loop.
I would like to display each image, close it if I use the key ‘q’, and continue reading images.
My code is something like this:
<code>for idx in range(total_files):
image_path = image_paths[idx]
image = cv2.imread(image_path)
cv2.imwrite(filename, image)
cv2.imshow("image", image)
if cv2.waitKey(0) == ord("q"):
cv2.destroyAllWindows()
</code>
<code>for idx in range(total_files):
image_path = image_paths[idx]
image = cv2.imread(image_path)
cv2.imwrite(filename, image)
cv2.imshow("image", image)
if cv2.waitKey(0) == ord("q"):
cv2.destroyAllWindows()
</code>
for idx in range(total_files):
image_path = image_paths[idx]
image = cv2.imread(image_path)
cv2.imwrite(filename, image)
cv2.imshow("image", image)
if cv2.waitKey(0) == ord("q"):
cv2.destroyAllWindows()
The image is correctly read and saved. However, the execution freezes indefinitely without ever displaying an image.
Any help in this will be highly appreciated.
Thank You