[英]CIFilter filterWithCVPixelBuffer returning nil in iOS
我正在嘗試使用filterWithCVPixelBuffer創建CIFilter,並且返回nil。 這就是我想要做的:
CFDictionaryRef options = CMCopyDictionaryOfAttachments(nil, photo.pixelBuffer, kCMAttachmentMode_ShouldPropagate);
CIFilter * ciFilter = [CIFilter filterWithCVPixelBuffer:photo.pixelBuffer properties:(__bridge NSDictionary*)options options:nil];
photo是提供給委托人的AVCapturePhoto的實例。 我正在使用iOS 12,並在iPhone7上運行代碼。
問題出在屬性NSDictionary中。 我應該簡單地通過photo.metadata。 因此,函數調用如下所示:
CIFilter * ciFilter = [CIFilter filterWithCVPixelBuffer:photo.pixelBuffer properties:photo.metedata options:nil];
當然,您可以傳遞包含所需CIRAWFilterOption(s)
的NSDictionary
。
我想我在頭文件的文檔中找到了答案:
返回一個CIFilter,該CIFilter隨后將返回經過正確處理的CIImage作為“ outputImage”。
注意,使用該初始值設定時,你應該在一個CVPixelBufferRef通過用下面的原始像素格式類型kCVPixelFormatType_14Bayer_GRBG,kCVPixelFormatType_14Bayer_RGGB,kCVPixelFormatType_14Bayer_BGGR,kCVPixelFormatType_14Bayer_GBRG以及從CMSampleBufferRef根屬性附件中的一個。
因此,我猜想這種方法應該在有CMSampleBuffer
情況下使用,而從AVCapturePhoto
時不可行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.