JPG/PNG压缩前先纵向翻转图片

This commit is contained in:
gb 2024-02-28 17:52:40 +08:00
parent 5524999d51
commit bf939b8c96
1 changed files with 4 additions and 1 deletions

View File

@ -99,9 +99,12 @@ std::shared_ptr<std::vector<uchar>> img_encoder::encode(LPPACKIMAGE head, cv::Ma
} }
else else
{ {
cv::Mat out;
cv::flip(mat, out, 0);
ptr.reset(new std::vector<uchar>()); ptr.reset(new std::vector<uchar>());
head->format = fmt_ == ".jpg" ? IMG_FMT_JPEG : IMG_FMT_PNG; head->format = fmt_ == ".jpg" ? IMG_FMT_JPEG : IMG_FMT_PNG;
cv::imencode(fmt_.c_str(), mat, *ptr, param_); cv::imencode(fmt_.c_str(), out, *ptr, param_);
head->prc_time = watch.elapse_ms(); head->prc_time = watch.elapse_ms();
printf("encode to '%s' in %ums: %u\n", fmt_.c_str(), head->prc_time, ptr->size()); printf("encode to '%s' in %ums: %u\n", fmt_.c_str(), head->prc_time, ptr->size());
} }