c++ - OpenCV: PNG image with alpha channel -


i'm new opencv , i've done small poc reading image url.
i'm reading image url using video capture. code follows:

videocapture vc; vc.open("http://files.kurento.org/img/mario-wings.png"); if(vc.isopened() && vc.grab())  {        cv::mat logo;        vc.retrieve(logo);        cv::namedwindow("t");        imwrite( "mario-wings-opened.png", logo);        cv::imshow("t", logo);        cv::waitkey(0);        vc.release(); } 

this image not opened correctly, possibly due alpha channel. way preserve alpha channel , image correctly?

any appreciated.
-thanks

expected output

expected output

actual output

actual output

if loading image, recommend use imread instead, also, need specified second parameter of imread load alpha channel too, cv_load_image_unchanged or cv::imread_unchanged, depending on version (in worst case -1 works).

as far know, videocaptureclass not load images/video 4th channel. since using web url, loading image won't work imread, may use method download data (curl example) , use imdecode data buffer cv::mat. opencv library image processing, not downloading images.


Comments