Ask Your Question
0

Convert Mat to std::set

asked 2015-11-05 07:39:53 -0500

thdrksdfthmn gravatar image

I have a cv::Mat that contains labels (the name of each class used in the training of a classifier). Now I want to check for confusion matrix from the labels and the predictions. I am doing this for each class, so I have done it in a function that I want to call for each label, so, it would be nice to create a std::set of labels. The labels are of type float, so the cv::Mat is CV_32F, but cv::Mat::data, cv::Mat::datastart and cv::Mat::dataend are *uchar, so the std::set is not having the correct labels.

std::set< float > lbls(lblMat.datastart, lblMat.dataend); // should be 100, 101, 102, ...
                                                          // but is 0, 63, 72, ...

Any other ideas, please?

edit retag flag offensive close merge delete

Comments

Waw, I didn't know that the operator = (flom std::vector) has this functionality, too. Thanks

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-11-05 08:12:08 -0500 )edit

@LorenaGdL You can convert your comment to answer, it worked well

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-11-05 09:09:17 -0500 )edit
LorenaGdL gravatar imageLorenaGdL ( 2015-11-05 09:14:31 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-11-05 08:04:30 -0500

LorenaGdL gravatar image

updated 2015-11-05 09:13:52 -0500

Mat labelsMat = (Mat_<float>(8, 1) << 101, 101, 103, 102, 105, 101, 103, 103);
vector<float>labelsVec = labelsMat;
set<float>labelset(labelsVec.begin(), labelsVec.end());
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-11-05 07:39:53 -0500

Seen: 203 times

Last updated: Nov 05 '15