OpenCV2.3 imwrite saves black image

后端 未结 3 1302
忘掉有多难
忘掉有多难 2021-01-21 13:25

I am trying to save a JPEG image onto the disk using imwrite, seems that I am missing something. I am always getting a black image of around 4KBs. What am I doing wrong here? Im

3条回答
  •  伪装坚强ぢ
    2021-01-21 13:57

    The following code works for me on 8bit (1 and 3 channel) images:

    std::vector qualityType;
    qualityType.push_back(CV_IMWRITE_JPEG_QUALITY);
    qualityType.push_back(90);
    cv::imwrite("Final.jpg",image,qualityType);
    

    In your code qualityType is initialized incorrectly. Your vector contains 2 values

    {, CV_IMWRITE_JPEG_QUALITY}
    

    but should be

    {CV_IMWRITE_JPEG_QUALITY, }
    

提交回复
热议问题