aihot  2017-05-16 07:11:41  OpenCV |   查看评论   
 -1;  
  •     }  
  •   
  •     std::string save_image = "E:/GitCode/OpenCV_Test/test_images/1_1.jpg";  
  •     cv::imwrite(save_image, mat1);  
  •   
  •     // cv::imdecode/cv::imencode  
  •     std::ifstream file(image_name.c_str(), std::ios::in | std::ios::binary | std::ios::ate);  
  •     if (!file.is_open()) {  
  •         fprintf(stderr, "open file fail: %s\n", image_name.c_str());  
  •         return -1;  
  •     }  
  •   
  •     std::streampos size = file.tellg();  
  •     file.seekg(0, std::ios::beg);  
  •     std::string buffer(size, ' ');  
  •     file.read(&buffer[0], size);  
  •     file.close();  
  •   
  •     std::vector<char> vec_data(&buffer[0], &buffer[0] + size);  
  •     cv::Mat mat2 = cv::imdecode(vec_data, 1);  
  •     std::string save_image2 = "E:/GitCode/OpenCV_Test/test_images/2_1.jpg";  
  •  

    除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自OpenCV中imread/imwrite与imdecode/imencode的异同

    留言与评论(共有 0 条评论)
       
    验证码:
    [lianlun]1[/lianlun]