Ask Your Question

GpuMat and std::vector

asked 2012-10-22 16:46:54 -0600

andreas_ gravatar image

updated 2012-10-24 02:35:16 -0600

Kirill Kornyakov gravatar image

Hi all,

what is the appropriate way to store GpuMats in a container. So far I'm using std::vector<cv::gpu::GpuMat> But I'm wondering how the GpuMats are stored in the vector. Does the vector create copies of the matrices on the GPU memory? If so, it's probably not very efficient. What would be the best solution? Would it make more sense to use std::vector<cv::gpu::GpuMat*> or better std::vector < boost::shared_ptr <cv::gpu::GpuMat> > ?

Cheers, Andreas

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2012-10-23 01:30:57 -0600

Vladislav Vinogradov gravatar image

You can store GpuMat in vector. GpuMat and Mat is smart pointers to data with reference counting. It doesn't create copy of data in copy constructor:

GpuMat a(100,100,CV_8U);
GpuMat b = a; // b and a shares the same data
edit flag offensive delete link more


Thanks! Good to know :)

andreas_ gravatar imageandreas_ ( 2012-10-23 08:55:29 -0600 )edit

Question Tools


Asked: 2012-10-22 16:46:54 -0600

Seen: 2,159 times

Last updated: Oct 24 '12