ios/iphone photo burst mode api

后端 未结 2 827
执笔经年
执笔经年 2021-02-04 17:51

I\'m trying to capture multiple photos on highest resolution(AVCaptureSessionPresetPhoto) on iPhone 5s. I tried using the following code:

    dispatch_semaphore_         


        
相关标签:
2条回答
  • 2021-02-04 18:07

    captureStillImageAsynchronouslyFromConnection:completionHandler: isn't, I believe, what Apple is using for its burst mode.

    Instead, Apple is* grabbing video frames at full resolution (which is supported by the 5s). Here's how:

    The AVCaptureDevice has its activeFormat set to full sensor resolution, then you grab and process 10 frames per second from AVCaptureVideoDataOutputSampleBufferDelegate's captureOutput:didOutputSampleBuffer:fromConnection:, firing off a shutter sound for each frame grab.

    You'll need to have a fall-back (either lower-resolution images or a slower burst mode) for devices that don't support video at the full sensor-size resolution—and/or if you want to support anything older than iOS 7.x.

    Note that you can't have multiple concurrent usage of captureStillImageAsynchronouslyFromConnection:completionHandler: without some extremely unexpected results. This is why you should call each iteration from the previous one's completionHandler (which, in essence, is what your semaphore is doing). Also, you may wish to switch from PNG as your file format for burst shots—it saves very slowly and requires a lot of system resource—stacking up 15 or 20 PNGs could cause you some serious grief!

    *It's probably doing this, because it may, of course, be using a private API to achieve the same end result.

    0 讨论(0)
  • 2021-02-04 18:21

    Use this method for burst mode in iOS 8 and above:

    - (void)captureStillImageBracketAsynchronouslyFromConnection:(AVCaptureConnection *)connection withSettingsArray:(NSArray *)settings completionHandler:(void (^)(CMSampleBufferRef sampleBuffer, AVCaptureBracketedStillImageSettings *stillImageSettings, NSError *error))handler NS_AVAILABLE_IOS(8_0);
    

    Documentation

    0 讨论(0)
提交回复
热议问题