5

I have a pycuda gpuarray that I would like to feed to an opencv cuda function. As I understand there are currently no python bindings for the opencv 3 cv::cuda module. So I tried writing my own python wrapper for accessing cv::cuda functions (in my case cv::cuda::HOG class).

Unfortunately I hit a road block when it comes to the central part of data exchange. I know that you can use a structure like

static PyObject* my_function(PyObject* self, PyObject* args)
{
  int test;
  PyArg_ParseTuple(args, "t", &test);
}

To pass elementary data types, but I do not know how to do that with pointers on gpu memory (in my case gpuarray.gpudata). My understanding is that gpuarray.gpudata yields a pointer according to the dtype of the gpuarray but on the gpu.

So on the python side things would look like this:

input_gpu = gpuarray.zeros(shape=(3,3), dtype=numpy.float32)
output_gpu = gpuarray.zeros(shape=(3,3), dtype=numpy.float32)
my_function(input.gpudata, output.gpudata)

On C++ side I would have to use cv:cuda::GpuMat, so how to I get from gpuarray.gpudata to cv:cuda::GpuMat and vice versa?

talonmies
  • 70,661
  • 34
  • 192
  • 269
Wizard
  • 295
  • 1
  • 4
  • 15

0 Answers0