I was wondering if there is a way to easily determine the compression ratio when compressing images on opencv without declaring a dummy vector. If I declare a vector p (similar to this discussion ), but containing only 2 elements, which imwrite does, I can make a call:
vector<int> p; p[0] = CV_IMWRITE_JPEG_QUALITY; p[1] = 50;
The above works fine. However, I want to compress the same image with multiple compression ratios in a loop. Is there a way to explicitly pass the imwrite parameter? Sort of:
imwrite("compressed.jpg", img, {CV_IMWRITE_JPEG_QUALITY, factor});
As a note, the function header:
bool imwrite(const string& filename, const Mat& img, const vector<int>& params=vector<int>());
Thanks!
Update: After activating C ++ 0x, I can pass a vector explicitly defined in the function string.
source share