opencv加载png图片

2022-03-31  本文已影响0人  懂你的

int main(int argc, const char *argv[]){

string image_path = "/Users/zhangbenxing/PycharmProjects/test_std_stream/xx.png";

    std::ifstream input;

    input.open(image_path, std::ios::binary);

    std::vector<unsigned char> data(std::istreambuf_iterator<char>(input), {});

    std::vector<uchar> vectordata(data.begin(),data.end());

    cv::Mat data_mat(vectordata, true);

    cv::Mat image(cv::imdecode(data_mat,1));

    cv::imwrite("/Users/zhangbenxing/PycharmProjects/test_std_stream/ss.png", image);

}

上一篇 下一篇

猜你喜欢

热点阅读