【发布时间】:2015-08-06 12:14:20
【问题描述】:
尝试压缩一些有一定难度的图片描述符,举个例子:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <opencv2/core.hpp>
int main(int argc, char *argv[])
{
// create some random descriptor 1 rows x 10 cols and populate with some data
const cv::Mat A = (cv::Mat_<float>(1,10) << 0, -1.5f, -2.f, -3.5f, -3.f, -5.f, -2.f, -2.f, 0, -1.f);
std::cout << "DESCRIPTOR A : " << std::endl << A << std::endl;
// create PCA and pass descriptor data with no mean and 6 max components
cv::PCA pca(A, cv::Mat(), CV_PCA_DATA_AS_ROW, 6);
// project A to compressed descriptor B (expecting 1 rows x 6 cols)
const cv::Mat B = pca.project(A);
std::cout << "DESCRIPTOR B : " << std::endl << B << std::endl;
return EXIT_SUCCESS;
}
输出:
DESCRIPTOR A :
[0, -1.5, -2, -3.5, -3, -5, -2, -2, 0, -1]
DESCRIPTOR B :
[0]
我知道 PCA 试图转换坐标系以表示具有较少维度的值,这是使用所有可用描述符完成的吗? IE。 PCA 类是否需要使用所有描述符来构造?如果是这样,如果他们不知道怎么办?
注意:使用 OpenCV 3.0.0 附加说明:在我的实际代码中,描述符的尺寸为 1 行 x 1000 列,但它仍在输出 [0]
【问题讨论】: