Introduction to Android_Camera preview data format Nv21

Introduction to Android Camera's preview data format Nv21

When the camera is enabled in Android to take pictures, it usually involves the preview callback function, and the parameters are generally: byte[] data, Camera camera. Without conversion, here byte[] datais the image information in Nv21 format, and what kind of image format is Nv21?

1. Prerequisite knowledge

Familiar RGBand not-so-familiar YUVare both artificially defined color spaces, which can be simply thought of as a highly abstract system for images, used to describe images. Just as people can abstract such a system: "objects" composed of organs such as eyes, nose, mouth, ears, etc., they can also abstract such a system: name, date of birth, etc. The "objects" of these two "systems" can be used to describe a specific person by concretizing the information in them. Similarly, for objects such as images (videos are considered to be composed of many images), there are also many sets of description systems.

1.1 RGB

The RGB color mode is a color standard in the industry, and various colors are obtained by changing the three color channels of red®, green (G), and blue (B) and superimposing them with each other. RGB is the color that represents the three channels of red, green, and blue. This standard includes almost all colors that human vision can perceive, and is one of the most widely used color systems . --Baidu Encyclopedia

When adding transparency as a "descriptor" color space:RGBA

RGB (Red Green Blue) is a space defined based on the colors recognized by the human eye, and can represent most colors. However, the RGB color space is generally not used in scientific research, because its details are difficult to digitally adjust. It puts the three quantities of hue, brightness, and saturation together, and it is difficult to separate them. It is the most general hardware-oriented color model. This model is used for color monitors and a large class of color video cameras - https://www.cnblogs.com/faith0217/articles/4262913.html

1.2

YUV , is a color encoding method. Often used in various video processing components. YUV takes human perception into account when encoding photos or videos, allowing bandwidth reduction for chroma.

YUV is a type of compiling true-color color space (color space). Proper nouns such as Y'UV, YUV, YCbCr , and YPbPr can all be called YUV, and they overlap with each other. "Y" stands for brightness (Luminance or Luma), that is, the gray scale value, "U" and "V" stand for chroma (Chrominance or Chroma), which are used to describe the color and saturation of the image, and are used to specify pixels s color. [1] ——Baidu Encyclopedia

In YUV space, each color has a luminance signal Y, and two chrominance signals U and V. The luma signal is the sense of intensity, and it is disconnected from the chrominance signal so that the intensity can change without affecting the color.

YUV uses RGB information, but it produces a black-and-white image from a full-color image, and then extracts the three main colors into two additional signals to describe the color. Combining these three signals back produces a full-color image.

The Y channel describes the Luma signal, which is slightly different from the Luma signal, with values ​​ranging between light and dark. Luma is the signal that black and white TVs can see. The U (Cb) and V (Cr) channels extract luminance values ​​from red (U) and blue (V) to reduce the amount of color information. These values ​​can be recombined to determine the mixed signal of red, green and blue. ——https://www.cnblogs.com/faith0217/articles/4262913.html

2. NV21

NV21The image format belongs to the format in the YUVYUV420SP color space . Every four Y components share a set of U components and V components. Y is sorted continuously, and U and V are sorted crosswise. ——https://www.jianshu.com/p/a8ae092bb8b8
The arrangement is as follows:

YY   YY YY YY
YY   YY YY YY

YY YY YY YY
YY YY YY YY

V U   V U   V U  V U

V U   V U   V U  V U

3. Summary:

So Nv21 is actually YUVa format described by color space. It is used as the output image format of the Android system camera by default. When necessary, it can be Bitmapconverted to a more commonly used format (reference: Nv21 to Bitmap (high-efficiency conversion) ).

Guess you like

Origin blog.csdn.net/teolih/article/details/120243335