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);