calcCovarMatrix crashes
I am trying to compute the covariance and mean of my data matrix where each row is a sample of 3 dimensions. I have printed temp_rgb_mat to verify that it has X rows and 3 columns. The code I have below keeps crashing though and even after googling for various threads I still cant seem to figure out the reason behind it.
//compute mean and covariance matrix of node
cv::Mat temp_rgb_mat(cv::Size(3, nodes[i].rgb.size()), CV_8UC1, nodes[i].rgb.data());
cv::calcCovarMatrix(&temp_rgb_mat, 1, nodes[i].covar_rgb, nodes[i].mean_rgb, CV_COVAR_NORMAL | CV_COVAR_ROWS);
nodes[i].rgb.data is a vector< Vec3b >. This is the error I receive
OpenCV Error: Assertion failed (data[i].size() == size && data[i].type() == type) in cv::calcCovarMatrix, file C:\Bin\opencv-master\source\modules\core\src\matmul.cpp, line 2525
error msg, please..
do i have to duplicate temp_rgb_mat then pass in the both of them ? it seems like that is what is required based on the docs...
http://docs.opencv.org/2.4/modules/co... calcCovarMatrix(const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, int ctype)