开发者

Video capture on an iPhone; captureOutput delegate never called

Hey folks. Trying to get started with iPhone video capture stuff, and having a terrible time getting it going.

At the moment, working with an exact copy of the sample code from this Apple Developer Q&A: qa1702; not going to re-paste it here, since it's a relatively big blob of code.

In any case, I copied and pasted that code into an otherwise-empty project, threw in a call to setupCaptureSession into a custom UIView, and figured I should be good to go:

- (void)awakeFromNib {
    NSLog(@"init");
    [self setupCaptureSession]; 
}

Un开发者_StackOverflow社区fortunately, when I run the code, my delegate never seems to be called:

- (void)captureOutput:(AVCaptureOutput *)captureOutput 
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer 
       fromConnection:(AVCaptureConnection *)connection
{ 
    NSLog(@"New Image!");
}

I'd expect to be seeing a flood of "New Image!" getting dumped to the log, but I'm getting absolutely nothing. I do know that all the initialization code is being run (I threw a few NSLog statements here and there within setupCaptureSession, and they all print).

So, I'd either A) like to figure out what I'm doing wrong or B) see some very simple capture code embedded into a UIView that actually works (the less code, the better). Ideally, the sample code would use the setupCaptureSession code as described in the Apple developer site above.

Note that this code is being tested on an iPhone 3GS running the newest version of iOS 4.

Thanks in advance!


I copied and pasted the same code into a new project and it works fine for me. Here is what I did:

I created a View Based application in XCode.

I added the following frameworks:CoreMedia, CoreVideo,AVFoundation

I imported AVFoundation into my viewcontroller's header file

I specified my view controller to use the AVCaptureVideoDataOutputSampleBufferDelegate protocol in its interface definition

In the implementation I copied the code from the app document you specified in your question

I commented out this:

 [self setSession:session]

I commented out this:

UIImage *image = [self imageFromSampleBuffer:sampleBuffer];

and added this:

NSLog(@"here");

In the viewDidLoad method i put

 [self setupCaptureSession];

Build. Run. The "here" gets printed repeatedly to the console.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜