日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

C++实现NV12格式转BGR

發布時間:2023/12/14 c/c++ 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C++实现NV12格式转BGR 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

NV12格式:

NV12 轉 BGR 使用opencv接口函數:

cv::cvtColor(img_nv12, img_BGR, cv::COLOR_YUV2BGR_NV12);

如果不可調用opencv,使用以下自定義函數實現:

static void NV12_T_BGR(unsigned int width, unsigned int height, unsigned char *yuyv,unsigned char *bgr) {const int nv_start = width * height;int i, j, index = 0, rgb_index = 0;unsigned char y, u, v;int r, g, b, nv_index = 0;for (i = 0; i < height; i++) {for (j = 0; j < width; j++) {nv_index = i / 2 * width + j - j % 2;y = yuyv[rgb_index];u = yuyv[nv_start + nv_index ];v = yuyv[nv_start + nv_index + 1];r = y + ((360 * (v - 128) + 128) >> 8);g = y - (((88 * (u - 128) + 184 * (v - 128)) - 128) >> 8);b = y + ((455 * (u - 128) + 128) >> 8);if (r > 255)r = 255;if (g > 255)g = 255;if (b > 255)b = 255;if (r < 0)r = 0;if (g < 0)g = 0;if (b < 0)b = 0;index = rgb_index % width + i* width;bgr[index * 3 + 2] = r;bgr[index * 3 + 1] = g;bgr[index * 3 + 0] = b;rgb_index++;}}}

總結

以上是生活随笔為你收集整理的C++实现NV12格式转BGR的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。