Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

python - How do I look through many images with a conditional element

I have a folder that contains hundreds of images.

I am looking for a way to look through each image individually and decide whether to keep its name or move to the next.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use the os and cv2 modules in python

import os
import cv2

path = 'path/to/folder/with 100 images'
arr = os.listdir(path)

for i in range(len(arr)):
    img = cv2.imread(path+arr[i])
    cv2.imshow(arr[i], img)
    k = cv2.waitKey(0)
    if(k == 113):
        cv2.destroyAllWindows()
        break
    cv2.destroyAllWindows()

This will open a window to view your image, all you have to do is press any key to move forward and load another image.

Press 'q' to exit.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...