Всех приветствую.
В процессе работы с OpenCV столкнулся с такой проблемой:
Рабочий стол, размером 1920x1080, весит аж 382784 байтов!
Начал искать в документации способ сжатия изображения.
Нашел такую статью:
В ней нашел такой код:
C: int cvSaveImage(const char* filename, const CvArr* image, const int* params=0 ) Parameters: filename – Name of the file. image – Image to be saved. params – Format-specific save parameters encoded as pairs paramId_1, paramValue_1, paramId_2, paramValue_2, ... . The following parameters are currently supported:
For JPEG, it can be a quality ( CV_IMWRITE_JPEG_QUALITY ) from 0 to 100 (the higher is the better). Default value is 95.
Как мне можно его сюда прикрутить?
Что-то типа такого:
int quality = 70;
imencode(".jpg", s, buf, quality);
Код:
Mat s;
vector<uchar> buf;
while (1) {
r->GetDesktopMat(s);
imencode(".jpg", s, buf);
cout << buf.size() << endl; // 382784 - 1920x1080 resolution
}