-3

I have a std::vector that I want to access on my host. How would I perform one batch memcpy operation (or download operation) to return a vector of cv::Mats? I am running this on the Jetson TX2, so I have the ability to do unified shared memory.

talonmies
  • 70,661
  • 34
  • 192
  • 269

1 Answers1

0

The easiest way is:

std::vector<cv::Mat> host;
// pre-allocate the memory.
host.reserve(devices.size());

cv::Mat tmp;
// Download each image one by one.
for(cv::cuda::GpuMat& d : devices)
{
  d.download(tmp);
  // Remember that the assignation between two cv::Mat does not do a copy but a reference sharing.
  host.push_back(tmp.clone());
}
John_Sharp1318
  • 939
  • 8
  • 19