Home > Mobile >  Creating alpha channel opencv
Creating alpha channel opencv

Time:05-22

I have a program in c and opencv2 that loads an mp4 file and gives me frame pixels. I have a problem opencv outputs 24 bits per pixel, and I need 32 to display in a window on winapi. Is it possible to create an empty alpha channel using standard opencv tools?

CodePudding user response:

You can use cv::cvtColor to convert a 3 channel RGB/BGR image to a 4 channel image with an additional alpha channel.
As you can see in the documentation link above, the 3rd parameter specifies the required conversion.

cv::Mat img24;  // initialized somehow
// ...
cv::Mat img32;
cv::cvtColor(img24, img32, CV_BGR2BGRA);
  • Related