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);
}
网友评论