如何从数据集读取所有图像并使用opencv将其存储在另一个位置。
import os
import cv2
SOURCE_FOLDER = "a"
DESTINATION_FOLDER = "b"
for image_file_name in os.listdir(SOURCE_FOLDER):
# get full path to image file
image_path = os.path.join(SOURCE_FOLDER, image_file_name)
# read image
img = cv2.imread(image_path)
# store image in another folder
image_write_path = os.path.join(DESTINATION_FOLDER, image_file_name)
cv2.imwrite(image_write_path, img)