Hello,
I've been trying to create an interface between ArrayFire and OpenCV. I want to take an RGB image that was stored as an ArrayFire array and convert it to an OpenCV GpuMat. OpenCV expects a packed image of unsigned integers while ArrayFire array stores the image as floats with each image channel as a separate plane.
I can convert the array to unsigned integers and reindex the array to repack the image for OpenCV. Then I can create the GpuMat with the device pointer of the array, I added a few lines below to try and show what I'm doing :
array input;
array input_u8 =
input.as(u8);
input_u8 = array(input_u8, dim4(height, width*channels);
input_u8 = input_u8(span, array(indices));
GpuMat myOpenCVImage(height, width, input_u8.device<uchar>()):
Where height and width are the height and width of the image and channels are the number of image planes which is 3 in this case. Indices is an array that re indexes the image into an RGB RGB RGB... format instead of a separate plane for each color channel. This allows me to get the image as an Opencv GpuMat. However, everytime this function is used (in my case, it is used in a while loop) I see that ArrayFire is allocating more memory until there is none left on the device and the ArrayFire throws an out of memory exception. I'm not sure why this is happening.
Just in case the af::info output is:
ArrayFire v3.1.0 (CUDA, 64-bit Linux, build a8d8837)
Platform: CUDA Toolkit 7, Driver: 346.46
[0] Quadro K4000M, 4096 MB, CUDA Compute 3.0
Adrian