2
votes

I am using OpenCV 3.0 with VS2012 C++/CLI on a Win 8.1 64 bit machine.

I am wondering what the proper way is to create a C++ pointer to a Gpumat.

Currently, I define some pointers, like:

cuda::GpuMat *d_gpuLoadFrame;
cuda::GpuMat *d_gpuLoadFrameClone;
cuda::GpuMat *d_gpuAnalysisFrame;
cuda::GpuMat *d_gpuGrayFrame;
cuda::GpuMat *d_gpuMaskFrame;
cuda::GpuMat *d_gpuFalseMaskFrame;

Then I allocate the pointers themselves like:

d_gpuLoadFrame = new cuda::GpuMat();
d_gpuLoadFrameClone = new cuda::GpuMat();
d_gpuAnalysisFrame = new cuda::GpuMat();
d_gpuGrayFrame = new cuda::GpuMat();
d_gpuMaskFrame = new cuda::GpuMat();
d_gpuFalseMaskFrame = new cuda::GpuMat();
d_gputFrame = new cuda::GpuMat();

I am seeing some weird behavior that is making me think this might be wrong. For examples, I upload a standard Mat into some of these and clone them in various ways and it looks like the C++ pointer is being lost.

Do I need to do something different to keep track of the Gpumats so that they are not destroyed as I move from function to function?

1

1 Answers

1
votes

There is no need for providing pointers in the manner you have shown. A GpuMat file can just be passed to a function simply by writing the name in the actual parameters of the calling function. While at the function side it can be accessed using reference shown as under:
GpuMat abc; foo(abc); //at the function definition void foo(GpuMat& abc) { ... }