【问题标题】:OpenCV: imread gives CV_8UC3, can't convert to CV_8UC4?OpenCV:imread 给出 CV_8UC3,不能转换为 CV_8UC4?
【发布时间】:2013-09-24 18:09:12
【问题描述】:

需要帮助我尝试使用 OpenCV 加载和转换的图像:

这是我的代码:

templ = imread("Template.bmp",-1);
cout<<"templ before convert: "<<type2str(templ.type())<<endl;
templ.convertTo(templ,CV_8UC4);
cout<<"templ after convert: "<<type2str(templ.type())<<endl;

这总是给我 CV_8UC3!图像不是为转换为 4 个通道或类似的东西而制作的吗?还是我需要一个比例因子(读一下这样的东西)?

感谢您的帮助, 最好的问候!

【问题讨论】:

    标签: c++ opencv


    【解决方案1】:
    cvtColor( src,dst, CV_BGR2BGRA );
    

    【讨论】:

    • 就这么简单!伟大的! :) 为什么 convertTo 没有帮助?
    • @Bl4cke4gle convertTo 不会改变频道数量,它只会改变频道类型。
    猜你喜欢
    • 2020-01-18
    • 1970-01-01
    • 2020-04-25
    • 1970-01-01
    • 1970-01-01
    • 2017-08-27
    • 2013-02-26
    • 2013-01-07
    • 2016-01-03
    相关资源
    最近更新 更多