I want to overlay two images (maybe different format (channels) with opencv. Originally I use addWeighted, however, it fails on two images with different channels. Is there any way in opencv that can handle this case? Thanks
解决方案
No, there is no API in OpenCV that offers this feature nativelly. On the other hand, there's nothing stopping you from writing your own code to do that.
A few weeks ago a made some changes to a function I saw somewhere else on the Internet to be able to:
Pass two input images: the background as BGR and the foreground as BGRA;
Blend them together according to a simple transparency rule;
(I don't remember where most of this code came from, sorry... but thank you whoever you are!)
void overlayImage(const cv::Mat &background, const cv::Mat &foreground, cv::Mat &output, cv::Point2i location, double opaci