Reading jpg file in OpenCV vs C# Bitmap

前端 未结 2 1105
眼角桃花
眼角桃花 2021-01-20 21:09

After many experiments, I found that reading color jpg file in C++ (OpenCV):

auto temp(cv::imread(\"xxx.jpg\");

is different from reading the s

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 21:54

    As others pointed out, if you want to read the image in OpenCV unmodified, set the flags to -1 in the C++ function, as in:

    cv::Mat img = cv::imread("xxx.jpg", -1);
    

    or use the defined enum value:

    cv::Mat img = cv::imread("xxx.jpg", cv::IMREAD_UNCHANGED);
    

    Also note that JPEG images are not guaranteed to be decoded bit-exactly the same by different decoders! It is preferable to use a lossless format like PNG instead (see #4148, #4046, ...).

提交回复
热议问题