我正在尝试使用opencv在wiki数据集中加载图像,其中的图像被组织到99个文件夹中。我有这个密码。你知道吗
def load_images(self,dataframe):
if dataframe is None:
return None
else:
assert type(dataframe) == pd.core.frame.DataFrame, "argument to load image should be dataframe"
assert "file_location" in dataframe.columns, "dataframe should contain file_location column"
output_images = np.zeros((len(dataframe),self.config.image_shape[0],self.config.image_shape[1],self.config.image_shape[2]))
for index,row in dataframe.iterrows():
img = cv2.imread(os.path.join(self.config.dataset_dir,row["file_location"][0]))
if img is None:
Log.WARNING("Unable to read images from "+os.path.join(self.config.dataset_dir,row["file_location"][0]))
continue
face_location = row["face_location"][0].astype(int)
face_image = img[face_location[1]:face_location[3],face_location[0]:face_location[2]]
face_image = cv2.cvtColor(face_image,cv2.COLOR_BGR2GRAY)
face_image = cv2.resize(face_image,(self.config.image_shape[0],self.config.image_shape[1]))
output_images[index] = face_image.reshape(self.config.image_shape)
return output_images
我想在运行代码时删除这样的错误
libpng warning: iCCP: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG
目前没有回答
相关问题 更多 >
编程相关推荐