Conversion from BGR to YUV for Nvidia encoder SDK
Hi, I am a beginner at OpenCV so, I request you to explain in a very simple way. Here is my code using which I am trying to convert BGR to YUV 444 packed format and writing to a file.
cv::cuda::GpuMat yuvFrame(height, width, CV_8UC3)
cv::cuda::cvtColor(bgrFrame, yuvFrame, cv::COLOR_BGR2YUV);
yuvFrame.download(yuv_cpu);
fwrite(yuv_cpu.data, 1, width * height * 3, fileWriter);
In COLOR_BGR2YUV
, the YUV format is packed YUV 444. I want an output format which is compatible with Nvidia Encoder SDK.
When I try to use the YV12 - COLOR_BGR2YUV_YV12
or IYUV - COLOR_BGR2YUV_IYUV
, the cvtColor function is giving me some memory exception error (do I need to initialize that GpuMat in a different way? Any code snippet would be helpful).
I could not find conversions from BGR to any of ARGB, ABGR, YUV420, NV12, YUV444 Planar - which are also supported by Nvidia SDK.
Are you sure that conversion is supported by the CUDA modules? I ask because I had a quick look and could not find an implementation or a test of this functionality.
The conversion from BGR to YUV is supported by cuda. (YUV 444 packed). But I was not able to convert BGR to YV12 or IYUV.