opencv 将Mat转为图片数据

先记录下来,以后有空在整理


    Mat img = imread("002.png", CV_LOAD_IMAGE_COLOR);


    std::vector data_encode;
    try
    {
        std::vector<int> param = std::vector<int>(2);
        param[0] = CV_IMWRITE_PNG_COMPRESSION;
        param[1] = 3;
        imencode(".png", img, data_encode, param);

    }
    catch (Exception& e)
    {
        const char * s_ERROR = e.what();
        std::string a(s_ERROR);
        int c = 0;
        c++;
    }

    int g =data_encode.size();

//获取图片数据指针
    unsigned char* tem = &*data_encode.begin();

你可能感兴趣的:(opencv,opencv,图片,数据,转化)