IÂ´m new in this forums and i have a doubt about Nvidia NPP. IÂ´m working with openCV and i want to integrate NPP to acelerate the computional cost during process images.
I donÂ´t know the function that it moves the web camÂ´s capture host to the device. I suposse that we have to reserve memory in device with function Malloc and later change the position of the image to device. I have this, but later…??
You’re right you need to allocate memory on the device, then transfer each frame from the webcam to the GPU for processing. You can do that either using the CUDA API calls (cudaMalloc / cudaMemcpy2D), or NPP comes with some utility classes (npp::ImageNPP_8u_C1 etc) which have constructors which copy the data from the host.
Bare in mind something I’ve found a few moments ago, that the ImageCPU NPP utility class does not allocate page-locked memory. That means you cannot use the asynchronous transfer functionality in CUDA (cudaMemcpyAsync etc), in my particular case this means I cannot concurrently upload several camera feeds to the GPU.
OpenCV includes some functionality that can pull frames from most standard webcams, you will still need that or another SDK to replace it. NPP doesn’t do device interfacing.
Your code is slightly off, but you’re almost there. Don’t think NPP supports 64 bit float images (don’t think Opengl does either, based on the colour range of your monitor). I just wrote this code into the forum, it won’t compile but should give you an idea.
I guessed “ImageNPP_32f_C4”, because in your example you used CV_64 for a type.
npp::ImageNPP_32f_C4 is the 32-bit float 4-channel version of the NPP structures, you need to use the right structure for the type of image that your webcam is loading. For 32-bit float images it will expect the colour values to be normalized between 0 and 1, a floating point value. For instance my cameras load 8-bit char data from the camera, and therefore I use the npp::ImageNPP_8u_C4 structure.
The imageData member is always a pointer to char* data because a char is always 8-bits, 1 byte. In the case of a 32-bit float image you can assume that each 4 elements are a float. Effectively in your case you should be able to cast (npp32f*), as long as the OpenCV image contains normalized float data.