Reading jpg file in OpenCV vs C# Bitmap

前端 未结 2 1104
眼角桃花
眼角桃花 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, ...).

    0 讨论(0)
  • 2021-01-20 22:00

    Maybe you can use getImage() instead of getMat()?

    A similar question is being addressed here (using openCV in C# not C++)
    http://www.emgu.com/forum/viewtopic.php?t=188

    0 讨论(0)
提交回复
热议问题