1. 程式人生 > >opencv 將Mat轉為圖片資料

opencv 將Mat轉為圖片資料

先記錄下來,以後有空在整理


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


    std::vector<uchar> 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();