ML::EM with multiple Features
Hello
I have a float[33] sized feature vector derived from pcl (Point Cloud Library). I would like to perform a Gaussian Mixture Model on this and found that OpenCV has this implemented in ML::EM.
I use OpenCV 3.0. Now unfortunately the EM model needs a one channel matrix. Does this mean I can only calculate a one dimensional Model? I have 33 features, not only one.
Here is my class where I convert my pcl feature PointCloud to OpenCV:
FPFHtoCV::FPFHtoCV(pcl::PointCloud<pcl::FPFHSignature33>::Ptr fpfhs)
{
cv::Mat openCVPointCloud( fpfhs->points.size(), 1, CV_32FC(33));
for(int i=0; i < fpfhs->points.size();i++)
{
pcl::FPFHSignature33 p = fpfhs->points.at(i);
for(size_t j = 0; j < 33; j++)
{
openCVPointCloud.at<cv::Vec<float,33> >(1,0)[j] = p.histogram[j];
}
}
_mat = openCVPointCloud;
}
And here how I try to run the GMM on the OpenCV matrix.
FPFHtoCV ftc(fpfhs);
cv::Mat mat = ftc.mat();
cv::Ptr<cv::ml::EM> source_model = cv::ml::EM::create();
source_model->setClustersNumber(6);
cv::Mat logs;
cv::Mat labels;
cv::Mat probs;
source_model->trainEM(mat,logs,labels,probs);
It does not work of course, as there is more than one channel.
what about reshaping your Mat, so it's [33, rows] , and single channel ?
why did you set it up like this (with only 1 col, but 33 channels) in the 1st place ?
@berak I consider this 33 featuers per point similar to something like rgb. While it is not color information it is addtional non spatial information. As OpenCV is for picture anaylsis I just assumend setting up mat[33,row s] with 1 channel would result in 33xrows 1 dimensinoal observations put into the EM algorithm. Will try though as suggested.