I\'m captuting video with AVCaptureSession. But I would like to convert the captured image to an UIImage.
I found some code on Internet:
- (UIImage *
Your best bet will be to set the capture video data output's videoSettings to a dictionary that specifies the pixel format you want, which you'll need to set to some variation on RGB that CGBitmapContext can handle.
The documentation has a list of all of the pixel formats that Core Video can process. Only a tiny subset of those are supported by CGBitmapContext. The format that the code you found on the internet is expecting is kCVPixelFormatType_32BGRA
, but that might have been written for Macs—on iOS devices, kCVPixelFormatType_32ARGB
(big-endian) might be faster. Try them both, on the device, and compare frame rates.