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: 
I think `std::copy` is better:

```
std::vector<float> vec;
vec.resize(numCols); 
std::copy(fooRow.data, fooRow.data + numCols, vec.begin());

```

Note that the second argument is : `fooRow.data + numCols`, as opposed to `fooRow.data + sizeof(float)* numCols`.

Also, in your code `vec.resize(numRows);` doesn't seem to be correct. It should be :

```
 vec.resize(numCols);

```

Because `fooRow` is ONE row, and has`numCols` number of values in it.
Possibly [this](http://answers.opencv.org/question/3386/gpumat-and-stdvector/) post may answer your question.