Question: 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?

Answer: 
Here is the method that does not produce any unnecessary copying:

```
GpuMat fooGpu(numRows, numCols, CV_32FC1);
std::vector<float> vec;
vec.resize(numCols);
fooGpu.row(i).download(Mat(vec).reshape(1/*channels*/, 1/*rows*/));

```
Possibly [this](http://answers.opencv.org/question/3386/gpumat-and-stdvector/) post may answer your question.