Post

Replies

Boosts

Views

Activity

Reply to Unable to use new CIRAWFilter API in iOS 15
I have been running different tests with the new CiRawFilter class and it seems to work well for me on macOS 12.3.1 in a Playground in Xcode 13.3.1. I tried the code with both a raw photo from my Canon Camera (CR2 format) and a raw photo from my iPhone 11 (DNG format). I do not have access to ProRaw photos, though. BTW, I noticed that your rawFilter is not optional. Maybe this is the issue? Here my code: import Cocoa import Foundation import CoreImage import SwiftUI // Path to locally stored raw image, not ProRaw, from an iPhone 11 let rawimgpath = "/...path.../IMGAGE.dng" let rawimgurl = URL(fileURLWithPath: rawimgpath) // Initialising the CiRAWFilter with URL let rawfilter = CIRAWFilter(imageURL: rawimgurl) // Creating a CI Image let rawimg = rawfilter?.outputImage // Creating a CG Image let context = CIContext() let rawcgimg = context.createCGImage(rawimg!, from: rawimg!.extent) let rawuiimg = Image(decorative: rawcgimg!, scale: 1.0) // Printing the properties of the filter... this should also show your Gammut Mapping let rawFltProps = rawfilter?.properties // Printing the properties of the image... let rawImgProps = rawimg?.properties // This does not cause an error let isgammutMappingEnabled = rawfilter?.isGamutMappingEnabled // Returns (Optional)true // Note: The Ci rawfilter is always optional with the "?" ! PS: Please, use the "Code Block" feature in the editor for better readability of your code. Makes things a little easier ;-).
May ’22
Reply to Extracting RGGB values from RAW pixel buffer
Hi, I am having exactly the same issue. Did you find a solution? I have the raw data from a camera sensor with 14bit/pixel with an RGGB color-filter array (CFA). I tried so many things to convert this to a color image, while letting iOS/Swift take care of the demosaicing. It obviously can do it. No need for me to program the de-bayering myself and probably doing a poor job at it compared to what iOS could do. Here is my code, which only gets me black and white (or better grayscale) images: let dummyImg = UIImage(systemName: "star.fill")?.cgImage // imgRawData is a [UInt16] array var pixelBuffer: CVPixelBuffer? let attrs: [ CFString : Any ]  = [ kCVPixelBufferCGImageCompatibilityKey : kCFBooleanTrue as Any, kCVPixelBufferCGBitmapContextCompatibilityKey : kCFBooleanTrue as Any, kCVPixelBufferPixelFormatTypeKey : "rgg4" ] CVPixelBufferCreateWithBytes(kCFAllocatorDefault, width, height, kCVPixelFormatType_14Bayer_RGGB, &imgRawData, 2*width, nil, nil, attrs as CFDictionary, &pixelBuffer) let ciimg = CIImage(cvImageBuffer: pixelBuffer!) let context: CIContext = CIContext.init(options: [ CIContextOption(rawValue: "workingFormat") : CIFormat.RGBA16 ] ) guard let cgi = context.createCGImage(ciimg, from: ciimg.extent, format: CIFormat.RGBA16, colorSpace: CGColorSpace(name: CGColorSpace.sRGB), deferred: false) else { return dummyImg! } I also tried this more direct approach with VideoTools.... it just returns nil: var cgI: CGImage? VTCreateCGImageFromCVPixelBuffer(pixelBuffer!, options: nil, imageOut: &cgI) How did you solve it?
Mar ’21
Reply to How do I convert a CVPixelBuffer to Data?
... 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". 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!
Feb ’21
Reply to CIFilter: proper options to open Fujifilm .RAF RAW files?
I am stuck with a related issue. I have raw pixel data from a Sony chip in RGGB pixel arrangement. How do I assign/apply raw filter options with CIFilter? The Apple Developer Documentation says you have to provide an identifier hint in the options, but I have no clue how to do this... The only example I found is outdated and the syntax provided causes a type error. Any help or hint is highly appreciated. Thank you! This is what I do, but it does not work... let rfo = [ String(kCGImageSourceTypeIdentifierHint) : "com.sony.raw-image" ] as! [CIRAWFilterOption:Any] let cii = CIFilter(imageData: ddata , options: rfo).outputImage
Feb ’21
Reply to RoundedRectangle
Hi... same problem here! Did you solve it? I used .fill with .border and the edges are not rounded, either: RoundedRectangle(cornerRadius: 20.0, style: .circular ) .frame(width: 50.0 , height: 50.0 ) .border(Color.blue, width: 2 ) .foregroundColor(Color.orange.opacity(0.2))
Jan ’21