import os
import h5py
import shutil
path=os.path.join('CK+48','neutral')
print(path)
CK_path='cohn-kanade-images'
files=os.listdir(CK_path)
files.sort()
for subject_name in files:
print(subject_name)
subject_path=os.path.join(CK_path,subject_name)
emotion_file=os.listdir(subject_path)
emotion_file.sort()
for emotion_name in emotion_file:
print(emotion_name)
emotion_path = os.path.join(subject_path, emotion_name)
png_file = os.listdir(emotion_path)
png_file.sort()
print(png_file)
shutil.copy(os.path.join(emotion_path,png_file[0]),path)
只提取出来图片还是不够的,接下来是对图片进行处理,得到只含人脸部分,size为48*48,8-bit color的图片。
import dlib
import cv2
import os
import numpy as np
import shutil
import matplotlib.pyplot as plt
from PIL import Image
import skimage
datapath = 'neutralafter'
# if not os.path.exists(