Ask Your Question
0

Creating an array of Mats of size n

asked 2014-04-12 11:55:05 -0600

Luek gravatar image

I am trying to create an array of Mat objects to store images and am getting warnings for using anything other than a statically typed number such as 10

int numberOfRects = boundRect.size();
Mat image_array[numberOfRects];

When I try this code I get an error stating Variable length array of non-POD element type 'cv::Mat'

Same goes for this code: Mat image_array[boundRect.size()];

How can I create an array of Mats based on the size of boundRect?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-04-12 12:43:30 -0600

Guanta gravatar image

Static arrays need the size for their construction at compile time. If you want to have the size controlled at run-time, you need to either create the mat-array via new or use std::vector (I'd prefer the latter one, since when using new you'll also need to call delete[] and it also prevents you from writing at non existent memory).

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-04-12 11:55:05 -0600

Seen: 3,309 times

Last updated: Apr 12 '14