【发布时间】:2016-05-03 18:15:07
【问题描述】:
背景:假设我已经使用 PCACompute 在 python 中训练了一个 PCA,如下所示:
import numpy as np
import cv2 as cv
# generate some random data
data = np.random.sample(128)
for x in xrange(63): data = np.vstack((data, np.random.sample(128)))
print data.shape # (64, 128) i.e. 64 arrays of 128 dimensions
# train the PCA
mean, eigenvectors = cv.PCACompute(data, maxComponents=32)
print mean.shape # (1, 128)
print eigenvectors.shape # (32, 128)
问题:现在我有一个要使用 PCA 压缩的数组
sample = np.random.sample(128)
print sample.shape # (128,)
compressed_sample = cv.PCAProject(sample, mean, eigenvectors)
OpenCV 错误:断言失败 (mean.data && eigenvectors.data && ((mean.rows == 1 && mean.cols == data.cols) || (mean.cols == 1 && mean.rows == data.rows)))
【问题讨论】: