0

我的应用使用 AVCaptureSession 进行多次拍摄,类似于:

[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error){
     @try {
        if (imageSampleBuffer != nil) {             
            NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
            UIImage *image = [[UIImage alloc] initWithData:imageData];
            [self setImageView:imageView1 withImage:image];
        }
     }@catch (NSException *exception) {
     }@finally {}
}

当用户连续拍摄 10 次(每 1 秒启动一次)然后再重复 3 次时,应用程序在第 4 次崩溃。这很可能是因为内存问题。照片的设置是:

captureSession.sessionPreset = AVCaptureSessionPresetHigh;

这真的是 1280x720 - 不是最好的。当我切换到AVCaptureSessionPresetPhoto时,我得到了更好的照片分辨率,但现在在拍摄这 10 张照片时,应用程序第一次崩溃了。

我有两个主要问题。

1)我怎样才能保持高分辨率并且让应用程序不崩溃?

2)如何处理高分辨率图像数据使其足够高效?

注意:今天,我在拍摄过程中将接收到的图像数据设置到 UIImageView 中,拍摄完成后,我将每个 UIImageView 中的图像保存到硬盘;接收到每张图像后,这似乎比保存到硬盘驱动器更有效;但是,我仍然不喜欢这种方法。

PS:我见过经常拍摄多张高分辨率图像而没有任何内存问题的应用程序。

4

0 回答 0