Pythonは転送フォルダ内のすべてのファイルを抽出し、各フレームの方法を確認します。


pythonの中で経路の中の\を切り替え/転義を避けることができます。
os.walk方法は、ターゲットパスの下にあるファイルのroot、dirs、filesを抽出することができる。後に各ファイルを操作します。
スライス操作[:]は.jpgまたは.JPGファイルかどうかを判断する。
shutilのcopyメソッドは、ファイルを古いパスから新しいパスにコピーします。
globのglobメソッドは、ターゲットフォルダのすべての画像を抽出し、各画像を表示保存するなどの操作を行います。
詳細コードとコメントは以下の通りです。

import os
import shutil
import glob
import cv2
 
path = 'C:/Users/deepw/Desktop/testfile'
new_path = 'D:/new'
for root,dirs,files in os.walk(path): #        jpg            
  for i in range(len(files)):
    if files[i][-3:] == 'jpg' or files[i][-3:] == 'JPG':
      file_path = root + '/' + files[i]
      new_file_path = new_path + '/' + files[i]
      shutil.copy(file_path,new_file_path)
 
 
 
img_path = glob.glob('D:/new/*.jpg') #           
i=1
for each in img_path:
  img = cv2.imread(each, cv2.IMREAD_UNCHANGED)
  cv2.imshow('Image', img) #       
  k=cv2.waitKey(0) #           
  if k == ord('s'): #  s      ,              
    cv2.imwrite('D:/want/%d.jpg'%i,img,[int( cv2.IMWRITE_JPEG_QUALITY), 100])
    cv2.destroyAllWindows()
  else:
    cv2.destroyAllWindows()
  i=i+1
以上のPythonは転送フォルダ内のすべてを抽出しました。jpgファイルを確認して、各フレームの方法は小編集で皆さんに共有する内容です。参考にしていただければ幸いです。どうぞよろしくお願いします。