我是靠谱客的博主 精明冬日,这篇文章主要介绍OPENCV 将NV21数据转成jpg,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int nv21_2_jpeg(char *jpg_file_addr, char *nv21_addr, int nv21_width, int nv21_height) { if(!jpg_file_addr || !nv21_addr || nv21_width <= 0 || nv21_height <= 0) return -1; cv::Mat image_nv21(nv21_height + nv21_height / 2, nv21_width, CV_8UC1, (unsigned char *)nv21_addr); cv::Mat image_bgr; cvtColor(image_nv21, image_bgr, cv::COLOR_YUV2BGR_NV21); if(image_bgr.empty()) { printf("image_bgr empty n"); return -1; } std::vector<uchar> data_encode; std::vector<int> param = std::vector<int>(2); param[0] = CV_IMWRITE_JPEG_QUALITY; param[1] = 95; imencode(".jpg", image_bgr, data_encode, param); memcpy(jpg_file_addr,&*data_encode.begin(),data_encode.size()); return data_encode.size(); }

先贴代码,以后有空再整理。

最后

以上就是精明冬日最近收集整理的关于OPENCV 将NV21数据转成jpg的全部内容,更多相关OPENCV内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部