9

CVPixelBufferRefコピーの値を使用して元のピクセル バッファーをビット単位で操作できるようにするには、a のコピーを作成する必要があります。CVPixelBufferCreate、または でこれを達成できないようですCVPixelBufferCreateWithBytes

この質問によると、memcpy() でも実行できる可能性があります。ただし、これがどのように達成されるかについての説明はありません。また、どの Core Video ライブラリ呼び出しが必要になるかについても説明されていません。

4

3 に答える 3

1

Maxi Mus のコードは、RGB/BGR バッファを使用する予定です。そのため、コードの下の YUV バッファが機能するはずです。

// Copy the pixel buffer
    CVPixelBufferRef pixelBufferCopy = NULL;
    CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, bufferWidth, bufferHeight, pixelFormat, NULL, &pixelBufferCopy);
    CVPixelBufferLockBaseAddress(pixelBufferCopy, 0);
    //BGR
//    uint8_t *copyBaseAddress = CVPixelBufferGetBaseAddress(pixelBufferCopy);
//    memcpy(copyBaseAddress, baseAddress, bufferHeight * bytesPerRow);
    uint8_t *yDestPlane = CVPixelBufferGetBaseAddressOfPlane(pixelBufferCopy, 0);
    //YUV
    uint8_t *yPlane = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
    memcpy(yDestPlane, yPlane, bufferWidth * bufferHeight);
    uint8_t *uvDestPlane = CVPixelBufferGetBaseAddressOfPlane(pixelBufferCopy, 1);
    uint8_t *uvPlane = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1);
    memcpy(uvDestPlane, uvPlane, bufferWidth * bufferHeight/2);
    CVPixelBufferUnlockBaseAddress(pixelBufferCopy, 0);
于 2018-08-31T12:47:19.467 に答える