Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- calcCovarMatrix in multichannel image and unresolved assertion error
- Mat covar, selection, meanBGR;
- selection = src(roi);
- calcCovarMatrix(selection, covar, meanBGR, CV_COVAR_NORMAL|CV_COVAR_ROWS);
- vector<Scalar> samples;
- for(int i=0; i<selection.rows; i++) {
- for(int j=0; j<selection.cols; j++) {
- Scalar pixel = selection.at<Scalar>(i,j);
- Scalar sample(pixel[0], pixel[1], pixel[2]);
- samples.push_back(sample);
- }
- }
- calcCovarMatrix(samples, covar, meanBGR, CV_COVAR_NORMAL|CV_COVAR_ROWS);
- #include <opencv2/core/core.hpp>
- #include <opencv2/highgui/highgui.hpp>
- #include <iostream>
- using namespace cv;
- using namespace std;
- int main(int /*argc*/, char** /*argv*/)
- {
- Mat_<float> samples = (Mat_<float>(3, 3) << 1.0, 2.0, 3.0,
- 4.0, 5.0, 6.0,
- 7.0, 8.0, 9.0);
- Mat cov, mu;
- cv::calcCovarMatrix(samples, cov, mu, CV_COVAR_NORMAL | CV_COVAR_ROWS);
- cout << "cov: " << endl;
- cout << cov << endl;
- cout << "mu: " << endl;
- cout << mu << endl;
- return 0;
- }
- cov:
- [18, 18, 18;
- 18, 18, 18;
- 18, 18, 18]
- mu:
- [4, 5, 6]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement