c++ - Cannot load and overlay transparent image in OpenCV -


i have transparentgui.png image transparent background - in gimp looks that:

enter image description here

when load in opencv mat imgcolorpanel = imread("transparentgui.png", -1); , display imshow("widok", imgcolorpanel);, can see image white background (which wrong, because it should transparent):

enter image description here

eventually want overlay image (with it's transparent background) on camera captured image. if using other image, has background (so it's not transparent) - it's correctly overlayed.

however, when want overlay transparentgui.png image on captured camera image addweighted(imgcolorpanel, 0.8, imgoriginal, 0.6, 0, imgoriginal);, program crashes console error:

enter image description here

as debugging error:

enter image description here

everything works unless want load , display image transparent background. assume may conflict imgoriginal, because it's in hsv - building program object detection hsv colors, cannot change it. ok overlaing hsv image bgra image (the transparent one)? default color range of opencv bgr, camera capture image converted hsv, can overlay other image bgr - so, think else must problem.

imgcolorpanel , imgoriginal should have same size. statement, imgcolorpanel has 4 channels (rgba). make "addweighted" work, imgoriginal should have 4 channels, instead of 3 hsv channels.

for "imshow", think display issue, , may print out size of imgcolorpanel check if has 4 channels.


Comments