0
我目前正在使用前置攝像頭捕捉幀的iOS應用程序。我想比較實際的幀和以前的幀。爲了讓這個速度更快,我想創建8位灰度CGImage。如何從CIImage創建灰色8位CGImage?
我使用AVCaptureSession,我已經實現了委託:
func captureOutput(captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, fromConnection connection: AVCaptureConnection!) {
let image = CIImage(CVPixelBuffer: CMSampleBufferGetImageBuffer(sampleBuffer)).imageByApplyingOrientation(5)
let img = context.createCGImage(image, fromRect: image.extent(), format: kCIFormatBGRA8, colorSpace: CGColorSpaceCreateDeviceGray())
}
但是這給我描述崩潰,這種色彩空間是不受支持。你有什麼建議,我怎麼可以快速創建8位灰度CGImage?
感謝您的建議,但它不會幫助我。我有我自己的圖像處理算法,但首先我需要將圖像轉換爲灰度。 – MichalMoskala