基于openCV的图片查看器
最近更新:2024-09-23
|
字数总计:192
|
阅读估时:1分钟
|
阅读量: 次
1 2 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 cv2folder_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()
2023-12-06
该篇文章被 HolioFox
打上标签:
openCV
归为分类:
软件