I want to compress the contents of an OpenCV::cuda::GpuMat to H264. I don’t know much about OpenCV’s cuda::GpuMat class, but I know it allocates and uses cuda GPU memory buffers, and you can do all sorts of nifty cuda operations on them. I’d like to compress from one of these buffers to H264, but when I try to “map” or “register” the GpuMat to allow the encoder to use it directly, I get lost, and nothing seems to work. Calling NvEncRegisterResource( ), passing in NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR gives a return code of “device missing” or something like that. I don’t know what a “CudaDevicePtr” is, but I would guess it’s a pointer to cuda memory. But then, maybe not, the docs don’t specify.
One of the things that annoys me about OpenCV’s cuda::GpuMat is that it’s nothing more than a Gpu byte *, you can’t tell anything else about the class, as far as I can tell. I don’t know which video card it was allocated upon, or any other information about it at all.
Also, OpenCV allows one to “map” a DirectX texture to a “cudaGraphicsResource”, but I can’t figure out what a “cudaGraphicsResource” is useful for, or what it’s good for. My idea would be to try to find a way to allocate a DirectX texture, get a pointer to its Gpu bits on the NVidia card (by mapping/registering it with cuda?), then ALSO register this buffer with the encoder SDK. But, I have no idea how to create an OpenCV GpuMat on that buffer/texture so I can do the pre-encode buffer operations in OpenCV/Cuda! This is a mess.
can anybody offer some advice? I know this is poorly described.