开发者

Lag in output of AVCaptureSession

I am currently trying to implement a very simple UIView to replace the UIImagePickerController and am running into lag with the image being captured.

Here is the class I am currently using: https://gist.github.com/963319

When I call snapPicture the delegate gets back the image with correct dimensions instantaneously from captureOutput:didOutputSampleBuffer but does not disp开发者_JAVA百科lay the image for at least 3 seconds and sometimes takes up to 5 or 10 seconds. I have tried adding in the delegate setNeedsDisplay and setNeedsLayout. Does anyone have any idea what I might be doing wrong here or what might be causing this delay?


The docs of AVCaptureAudioDataOutput say "All delegate methods are called on the specified dispatch queue", so the answer below from Alex could well indicate the problem.

If you do something like this instead of the current delegate callback:

[delegate performSelectorOnMainThread:@selector(usePicture:) withObject:image waitUntilDone:NO];

The -usePicture: method then invokes the delegate with the new picture.

Works for me. Though only tested on iPhone 4 for now.

Regards, Edwin


Do you switch to main thread/queue when updating the UI in camView:didCaptureImage:? Updating UI from threads other than main causes issues.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜