| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 
 | import osimport cv2
 
 
 folder_path = 'D:/Users/image'
 
 
 image_files = [os.path.join(folder_path, file) for file in os.listdir(folder_path)
 if file.lower().endswith(('.png', '.jpg', '.jpeg'))]
 
 
 cv2.namedWindow('Image Viewer', cv2.WINDOW_NORMAL)
 
 
 current_index = 0
 total_images = len(image_files)
 
 while True:
 
 image_path = image_files[current_index]
 image = cv2.imread(image_path)
 
 
 cv2.imshow('Image Viewer', image)
 
 
 key = cv2.waitKey(0)
 
 
 if key == ord('a'):
 break
 elif key == ord('s'):
 current_index = (current_index + 1) % total_images
 elif key == ord('d'):
 current_index = (current_index - 1) % total_images
 
 
 cv2.destroyAllWindows()
 
 |