나는 이미지 크기가 640 x480
이고 출력 형식으로 yv12를 사용하고 싶습니다. 이미지가 일부 API에 의해 처리되고 있으며 출력을 YV12 형식으로 가져 오려고합니다.YUV420P 형식의 포맷 버퍼
내가 뭘 순간에 노력하고 있어요 것은 그
INT 폭 = 640;
int height = 480;바이트 [] byteArray = 새 바이트 [(* 너비 * 높이 + 높이 * 2) * 1.5)]);
captureDevice.GetPreviewBufferYCbCr (BYTEARRAY) ");
int YLength = Convert.ToInt32(width * height * 1.5);
// UVlength multipled by 2 because it is for both u and v
int UVLength = Convert.ToInt32(2 * (width/2) * (weight/2)) * 1.5);
var inputYBuffer = byteArray.AsBuffer(0, YLength);
var inputUVBuffer = byteArray.AsBuffer(YLength, UVLength);
var inputBuffers = new IBuffer[] { inputYBuffer, inputUVBuffer };
var inputScanlines = new uint[] { (uint)YLength, (uint)UVLength };
/////Creating input buffer that supports Nv12 format
Bitmap inputBtm = new Bitmap(
outputBufferSize,
ColorMode.Yvu420Sp,
inputScanlines, // 1.5 bytes per pixel in Yuv420Sp mode
inputBuffers);
//As v length is same as u length in output buffer so v length can be used in both place.
int vLength = UVLength/2;
var outputYBuffer = byteArray.AsBuffer(0, YLength);
var outputVBuffer = byteArray.AsBuffer(YLength, vLength);
var outputUBuffer = byteArray.AsBuffer(YLength + vLength, vLength);
var outputBuffers = new IBuffer[] { outputYBuffer, outputVBuffer, outputUBuffer };
//
var outputScanlines = new uint[] { (uint)YLength, (uint)vLength, (uint)vLength };
Bitmap outputBtm = new Bitmap(
outputBufferSize,
ColorMode.Yuv420P,
outputScanlines,
outputBuffers);**strong text**
그래서 난 내가 제대로 outputbuffer을 만드는 형식 YUV420P에 따라하고 그 물어보고 싶은 것을하는 내가 전달하고있는 API가 있습니다. 입력 버퍼에있는 NV12 및 YV12 (YUV420P) 형식으로 출력 버퍼를 제공 할 것이라고 가정합니다. 그래서 Y 평면을 만든 및 width x height x 1.5
바이트 .1.5 YV12 매트 및 유사하게 12 비트 때문에 U 평면에는 width/2 x height/2 x 1.5
바이트가 있고 마찬가지로 V 평면입니다. YUV420P 및 YVU420P에 대해서는 현재 형식이 정확하고 i가 올바른지는 상관하지 않습니다. 그냥 U와 V 비행기를 교환해야합니다.
이유는 다음과 같이 설명 할 수 있습니다. - byte [] byteArray = new byte [Convert.ToInt32 ((width * height + (2 * ((width * height)/4))) *)); – ashishdhiman2007