以下代码给出了不一致的协方差矩阵大小。
cv::Mat A = (cv::Mat_<float>(3,2) << -1, 1, -2, 3, 4, 0);
cv::Mat covar1, covar2, covar3, covar4, mean;
calcCovarMatrix(A, covar1, mean, CV_COVAR_NORMAL | CV_COVAR_ROWS);
calcCovarMatrix(A, covar2, mean, CV_COVAR_SCRAMBLED | CV_COVAR_ROWS);
calcCovarMatrix(A, covar3, mean, CV_COVAR_NORMAL | CV_COVAR_COLS);
calcCovarMatrix(A, covar4, mean, CV_COVAR_SCRAMBLED | CV_COVAR_COLS);
std::cout << "size: " << covar1.size() << "\n";
std::cout << "size: " << covar2.size() << "\n";
std::cout << "size: " << covar3.size() << "\n";
std::cout << "size: " << covar4.size() << "\n";
covar1
和covar2
应该具有相同的大小,因为它们都描述了行的协方差,covar3
和covar4
应该具有相同的大小,因为它们都描述分别在列上的协方差。但是,输出是:
size: [2 x 2]
size: [3 x 3]
size: [3 x 3]
size: [2 x 2]
答案 0 :(得分:1)
calcCovarMatrix()
docs,明确说明使用CV_COVAR_SCRAMBLED
&#34时;协方差矩阵为nsamples x nsamples
。&#34;