Iam尝试将PCA转换为RGB,但我收到错误:cv2.error: /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/color.cpp:3642: error: (-215) depth == CV_8U || depth == CV_16U || depth == CV_32F in function cvtColor
此错误是由行mean = cv2.cvtColor(mean, cv2.COLOR_RGB2BGR)
我的代码:
def featureExtract(self, images, dim, k = 4):
faces_rowvecs = []
nDim = None
for image in images:
image = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
nDim = image.shape
faces_rowvecs.append(image.flatten("C").copy())
faceData = np.vstack(faces_rowvecs)
pca = PCA(n_components=k)
pca.fit(faceData)
mean = pca.mean_
mean = mean.reshape(nDim[0],nDim[1], nDim[2])
mean = cv2.normalize(mean, dim, norm_type=cv2.NORM_MINMAX)
mean= cv2.cvtColor(mean, cv2.COLOR_RGB2BGR)