How can I transfer cv::gpu::GpuMat rows to std::vector with as little as possible copy operations?
The fastest way I can think of is:
GpuMat fooGpu(numRows, numCols, CV_32FC1);
Mat foo = fooGpu;
Mat fooRow = foo.row(i);
std::vector<float> vec;
vec.resize(numCols);
memcpy(&vec[0], fooRow.data, sizeof(float)*numCols);
But I’m not even sure if this works, because the fooRow content would have to be aligned…
Is there another (better) way to do it?
Here is the method that does not produce any unnecessary copying: