imageWithCVImageBuffer method always returns NULL
| Originator: | dgatwood42 | ||
| Number: | rdar://16357149 | Date Originated: | 3/18/2014 |
| Status: | Duplicate of 19296518 (Open) | Resolved: | |
| Product: | OS X | Product Version: | 10.9.2 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
The documentation for imageWithCVImageBuffer doesn't tell what situations it returns NULL. I'm seeing this reproducibly with a valid buffer, which could indicate that the API in question is simply broken, or it could indicate that there's some subtle precondition that I'm missing, and I have no idea which.
Steps to Reproduce:
To reproduce the problem trivially, grab the AVRecorder sample code project. In the AVRecorderDocument.m file, add this method:
-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
assert(imageBuffer != NULL);
CIImage *image = [CIImage imageWithCVImageBuffer:imageBuffer];
assert(image != NULL);
}
Then declare that the class conforms to AVCaptureVideoDataOutputSampleBufferDelegate. Finally, in its init method, add this:
self.videoPreviewOutput = [[AVCaptureVideoDataOutput alloc] init];
[self.videoPreviewOutput setSampleBufferDelegate: self queue:dispatch_get_main_queue()];
[session addOutput: self.videoPreviewOutput];
right after:
[session addOutput:audioPreviewOutput];
so that the method will get called. The method reliably crashes at the second assert, i.e. imageWithCVImageBuffer is completely nonfunctional. The same behavior occurs with the related initWith... method.
Expected Results:
I expected to get back a CIImage object.
Actual Results:
Got NULL.
Version:
10.9.2
Notes:
Configuration:
Current 15" Retina MacBook Pro (2.6 GHz)
Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!