cuốn sách gpt4 ai đã làm

ios - 使用 CVPixelBufferCreate 复制/复制 CVPixelBufferRef

In lại Tác giả: Taklimakan Thời gian cập nhật: 2023-11-01 21:33:24 46 4
mua khóa gpt4 Nike

Tôi cần tạo một CVPixelBufferRef Một bản sao của bộ đệm pixel gốc để có thể sử dụng các giá trị trong bản sao để thao tác theo bit với bộ đệm pixel gốc. Tôi dường như không thể sử dụng CVPixelBufferTạo hoặc CVPixelBufferTạoVớiByte đạt được mục đích này.

theo câu hỏi này , việc này cũng có thể được thực hiện bằng memcpy(). Tuy nhiên, không có lời giải thích nào về cách đạt được điều này cũng như không cần gọi thư viện video cốt lõi nào.

câu trả lời hay nhất

Điều này có vẻ hiệu quả:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {

CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

// Lấy thông tin vùng đệm pixel
const int kBytesPerPixel = 4;
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
int bufferWidth = (int)CVPixelBufferGetWidth(pixelBuffer);
int bufferHeight = (int)CVPixelBufferGetHeight(pixelBuffer);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer);
uint8_t *baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer);

// Sao chép vùng đệm pixel
CVPixelBufferRef pixelBufferCopy = NULL;
Trạng thái CVReturn = CVPixelBufferCreate(kCFAllocatorDefault, bufferWidth, bufferHeight, kCVPixelFormatType_32BGRA, NULL, &pixelBufferCopy);
CVPixelBufferLockBaseAddress(pixelBufferCopy, 0);
uint8_t *copyBaseAddress = CVPixelBufferGetBaseAddress(pixelBufferCopy);
memcpy(copyBaseAddress, baseAddress, bufferHeight * bytesPerRow);

// Thực hiện những việc cần làm với vùng đệm 2 pixel

}

Về ios - Sao chép/Sao chép CVPixelBufferRef bằng CVPixelBufferCreate, chúng tôi đã tìm thấy một câu hỏi tương tự trên Stack Overflow: https://stackoverflow.com/questions/37418517/

46 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress