-
-
Notifications
You must be signed in to change notification settings - Fork 56.4k
Closed
Milestone
Description
System Information
OpenCV version: 4.10.0-pre ( 4.9.0-522-g1fa96b161f )
Operating System / Platform: Ubuntu 24.04
Compiler & compiler version: GCC 13.2.0
Detailed description
Internal libjpeg-turbo is JPEG_LIB_VERSION=62.
opencv/3rdparty/libjpeg-turbo/CMakeLists.txt
Line 137 in 1fa96b1
| set(JPEG_LIB_VERSION 62) |
However, IMWRITE_JPEG_LUMA_QUALITY and IMWRITE_JPEG_CHROMA_QUALITY requests JPEG_LIB_VERSION >= 70.
opencv/modules/imgcodecs/src/grfmt_jpeg.cpp
Lines 786 to 801 in 1fa96b1
| #if JPEG_LIB_VERSION >= 70 | |
| if (luma_quality >= 0 && chroma_quality >= 0) | |
| { | |
| cinfo.q_scale_factor[0] = jpeg_quality_scaling(luma_quality); | |
| cinfo.q_scale_factor[1] = jpeg_quality_scaling(chroma_quality); | |
| if ( luma_quality != chroma_quality ) | |
| { | |
| /* disable subsampling - ref. Libjpeg.txt */ | |
| cinfo.comp_info[0].v_samp_factor = 1; | |
| cinfo.comp_info[0].h_samp_factor = 1; | |
| cinfo.comp_info[1].v_samp_factor = 1; | |
| cinfo.comp_info[1].h_samp_factor = 1; | |
| } | |
| jpeg_default_qtables( &cinfo, TRUE ); | |
| } | |
| #endif // #if JPEG_LIB_VERSION >= 70 |
Steps to reproduce
std::vector<uint8_t> jpegNormal;
cv::imencode(".jpg", src, jpegNormal);
std::vector<int> param;
param.push_back(IMWRITE_JPEG_LUMA_QUALITY);
param.push_back(95);
param.push_back(IMWRITE_JPEG_CHROMA_QUALITY);
param.push_back(80);
std::vector<uint8_t> jpegCustom;
cv::imencode(".jpg", src, jpegCustom, param);
and compare jpegNormal and jpegCustom.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)