... I know this is an old thread, but it looks like what I am trying to figure out. Maybe you could help me out ...
I have raw pixel data from a binary file and try to convert them into a CIImage. I decided to go via CVPixelBuffer in order to be able to provide the pixel layout (CFA) of my image sensor, which is a Sony RGGB (aka. "rgg4"). The rawImgData are [UInt16] with width*height number of elements, because I had to do some numerical treatment on the data.
This is how far I got so far. I am stuck with the pixel-buffer properties.
What do I have to put in the dictionary for CIFilter to create a raw image? I always get an error messages at line 10. The compiler does not like the "nil".
Code Block var pixelBuffer: CVPixelBuffer? |
let attrs: [ CFString : Any ] = [ kCVPixelBufferCGImageCompatibilityKey : kCFBooleanTrue as Any, |
kCVPixelBufferCGBitmapContextCompatibilityKey : kCFBooleanTrue as Any ] |
|
CVPixelBufferCreateWithBytes(kCFAllocatorDefault, width, height, kCVPixelFormatType_14Bayer_RGGB, &imgRawData, 2*width, nil, nil, attrs as CFDictionary, &pixelBuffer) |
|
let sourceTypeIdentifierHint = CIRAWFilterOption(rawValue: kCGImageSourceTypeIdentifierHint as String) |
|
let rfo: [CIRAWFilterOption: Any] = [ sourceTypeIdentifierHint : "com.sony.raw-image" ] |
let ciiraw = CIFilter(cvPixelBuffer: pixelBuffer, properties: nil, options: rfo).outputImage |
|
I put this in this thread, because one could imagine to convert the pixel buffer into data object and then omit the properties in CIFilter. But maybe, I would loose too much info from the pixel buffer. No clue.
Thank you for your help!