I want to process the live video from the camera frame by frame but when I try to convert my image to a cv::Mat I always get CGBitmapContextCreate: unsupported parameter combination: set CGBITMAP_CONTEXT_LOG_ERRORS environmental variable to see the details
. If I set that variable I get Assertion Failed(0)
SIGABRT.
I've tried with this method as well as with that included methond from ios.h but I still get the same result. I tried everything I could have found on SO. I presume the only thing that remains is that I don't know something in connection with my image when I convert the CMSampleBuffer
to UIImage
. Here is my code:
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!) {
DispatchQueue.global(qos: .background).async {
let pixelBuff = CMSampleBufferGetImageBuffer(sampleBuffer)
let ciImage:CIImage? = CIImage(cvPixelBuffer: pixelBuff!)
let img = UIImage(ciImage: ciImage!)
let i = self.cv.processImage(withOpenCV: img)
DispatchQueue.main.async {
self.imageView.image = i
}
}
}
I've also tried a lot of different methonds found on google to convert my buffer to a UIImage but still nothing. Do you have any idea?