Pruthvi P
Pruthvi P

Reputation: 534

How to initialise Mat data structure multiple times in opencv

The following will create 1 particle of Mat data structure and initialise it,

static Mat Particle = (Mat_<float>(4, 1) << 0, 0, 0, 0);

But how to create 100 such particles and initialise ?

Upvotes: 1

Views: 109

Answers (1)

Roger Rowland
Roger Rowland

Reputation: 26259

Maybe something like this (assuming you want them all initialised the same?) :

static Mat Particle = (Mat_<float>(4, 1) << 0, 0, 0, 0);

std::vector<Mat> pParticles;
for (int i = 0; i < 100; ++i)
{
    pParticles.push_back(Particle.clone());
}

Upvotes: 1

Related Questions