This might help. I was having the same issue (image not being drawn to screen) with this code.
Up vote 7 down vote favorite 3 share g+ share fb share tw.
I'm using the AVFoundation framework. In my sample buffer delegate I have the following code: -(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection{ CVPixelBufferRef pb = CMSampleBufferGetImageBuffer(sampleBuffer); CIImage *ciImage = CIImage imageWithCVPixelBuffer:pb; self.imageView. Image = UIImage imageWithCIImage:ciImage; } I am able to use the CIImage to run the face detector etc. but it does not show up in the UIImageView ... the imageView remains white.
Any ideas as to the problem? I am using the following to setup my session: self. Session = AVCaptureSession alloc init; self.session.
SessionPreset = AVCaptureSessionPreset640x480; self. VideoDevice = AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo; self. VideoInput = AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:nil; self.
FrameOutput = AVCaptureVideoDataOutput alloc init; self.frameOutput. VideoSettings = NSDictionary dictionaryWithObject:NSNumber numberWithInt:kCVPixelFormatType_32BGRA forKey:(id)kCVPixelBufferPixelFormatTypeKey; iphone ios avfoundation ios5 core-image link|improve this question asked Oct 17 '11 at 0:54user491880427210 53% accept rate.
This might help. I was having the same issue (image not being drawn to screen) with this code: CIImage *image = CIImage alloc initWithImage:UIImage imageNamed:@"mushroom. Jpg"; theImageView.
Image = UIImage imageWithCIImage:image; However, after changing the code to this, it now works correctly: CIImage *image = CIImage alloc initWithImage:UIImage imageNamed:@"mushroom. Jpg"; CIContext *context = CIContext contextWithOptions:nil; theImageView. Image = UIImage imageWithCGImage:context createCGImage:image fromRect:image.
Extent; To read more about CIContext take a look here: http://developer.apple.com/library/ios/#DOCUMENTATION/GraphicsImaging/Reference/QuartzCoreFramework/Classes/CIContext_Class/Reference/Reference.html#//apple_ref/occ/cl/CIContext.
Thanks -- this does indeed let me draw the image. However it leaks memory causing the app to crash after running a few seconds. – user491880 Oct 17 '11 at 2:08 Yea, I haven't really looked into it too much yet.
I'm sure you have to release the contexts or the CGImageRef at some point. Also I'm sure the method above isn't the practical way of using CIImage views. I plan to watch the "Using Core Image on iOS & Mac OS X" video (which is on the Apple Developer site, WWDC 2011 Session Videos) tomorrow and learn more in-depth, I'll drop a line if I learn anything useful.
– Murat Tulca Oct 17 '11 at 2:16 I recommend you also watch this video and/or look at the presentation slides as it explains how to use Core Image, and goes into detail about contexts and when to use CPU/GPU and more – Murat Tulca Oct 17 '11 at 21:17 I also found this to be useful: OpenGL ES Programming Guide for iOS developer.apple.com/library/ios/#documentation/3DDrawing/… – Murat Tulca Oct 17 '11 at 21:44 1 @akaru here's what UIImage reference says about its CGImage property: "If the UIImage object was initialized using a CIImage object, the value of the property is NULL". And it looks like UIImageView tries to access UIImage's CGImage in its implementation. This also looks to be the case for UIImagePNGRepresentation function - it returns nil if UIImage is not CGImage-based.
But +CIContext createCGImage: just does what it says - creates CGImage, so it works – Russian Oct 17 '117 at 13:25.
Here is one way that I got it to work: CIContext *context = CIContext contextWithOptions:nil; CGImageRef ref = context createCGImage:result fromRect:ciImage. Extent; self.imgView. Image = UIImage imageWithCGImage:ref scale:1.0 orientation:UIImageOrientationRight; CGImageRelease(ref); Note: Creating the context multiple times is really bad and actually causes a memory leak.
You should just create the context once as a property in your class instance and reuse it!
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.