Fill a std::vector with cv:Mat's

asked 2015-01-12 05:11:55 -0500

RiSaMa gravatar image

updated 2015-01-12 07:04:08 -0500

thdrksdfthmn gravatar image

Hi guys! I need your help, I hope you can help me.

I've created a struct:

struct clusters_t { 
        cv::Mat ids;
        cv::Mat means;
        vector<cv::Mat> covs;
        cv::Mat weights;
    } clusters;

And I have a problem filling the "covs". I reserve memory like I show below but... how can I copy a Mat inside the vector of mats??

clusters.covs.clear();
clusters.covs.reserve(0);

cv::Mat matrix;

newCovs.copyTo(clusters.covs.at(0));  //<-- DONT WORK... HOW CAN I COPY matrix inside the vector?

THANK YOU!!!!!!!!!!!!!!!!!!

edit retag flag offensive close merge delete

Comments

2

What about clusters.covs.push_back(newCovs.clone()) ?

Pedro Batista gravatar imagePedro Batista ( 2015-01-12 05:16:57 -0500 )edit

PERFECT!!! I LOVE YOU!! :)

RiSaMa gravatar imageRiSaMa ( 2015-01-12 05:21:36 -0500 )edit

I don't understand, if clusters it the name of the structure type, shouldn't clusters.covs not make sense ? And also what is newCovs ?

sup gravatar imagesup ( 2015-01-12 05:21:37 -0500 )edit