# How to use c++ opencv convert bgr(cv::Mat) to nv12(cv::Mat)

**URL:** <https://forum.opencv.org/t/how-to-use-c-opencv-convert-bgr-cv-mat-to-nv12-cv-mat/5215>\
**Category:** Uncategorized\
**Tags:** imgproc\
**Created:** [September 14, 2021, 4:38pm UTC](https://forum.opencv.org/t/how-to-use-c-opencv-convert-bgr-cv-mat-to-nv12-cv-mat/5215 "2021-09-14T16:38:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yahuuu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/yahuuu/32/3176_2.png) [@yahuuu](https://forum.opencv.org/u/yahuuu)\
**Post date:** [September 14, 2021, 4:38pm UTC](https://forum.opencv.org/t/how-to-use-c-opencv-convert-bgr-cv-mat-to-nv12-cv-mat/5215/1 "2021-09-14T16:38:56Z")

</div>

I know how to convert YV12 by CV\_BGR2YUV\_YV12, but not find 2NV12 or 2NV21. Hoping you can show me the code.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [September 14, 2021, 7:28pm UTC](https://forum.opencv.org/t/how-to-use-c-opencv-convert-bgr-cv-mat-to-nv12-cv-mat/5215/2 "2021-09-14T19:28:00Z")

</div>

> [@yahuuu](#):
>
> 2NV12 or 2NV21

how are those defined? I’ve never heard of those formats. I know NV12 and NV21.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [September 14, 2021, 7:40pm UTC](https://forum.opencv.org/t/how-to-use-c-opencv-convert-bgr-cv-mat-to-nv12-cv-mat/5215/3 "2021-09-14T19:40:37Z")

</div>

> [@yahuuu](#):
>
> to convert YV12 by CV\_BGR2YUV\_YV12

what do you want to do here ?  
a lot of devices _produce_ raw output in similar formats, but what is the conversion _from_ bgr for ?
