AVCaptureSession とリンゴの AVCam デモ アプリの多くのコードを使用して、独自のカスタム カメラ クラスを作成しました。基本的に、画像をキャプチャするために使用する機能は、アップルのアプリから逐語的ですが、写真を撮ると、コンソールにメモリ警告が表示されます。常に発生するわけではありませんが、ほとんどの場合、最初の画像で発生します。これは私の問題であるコードです..
- (void)capImage { //method to capture image from AVCaptureSession video feed
dispatch_async([self sessionQueue], ^{
// Update the orientation on the still image output video connection before capturing.
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
[[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:(AVCaptureVideoOrientation)orientation];
// Flash set to Auto for Still Capture
//[AVCamViewController setFlashMode:AVCaptureFlashModeAuto forDevice:[[self videoDeviceInput] device]];
// Capture a still image.
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (imageDataSampleBuffer)
{
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
[[[ALAssetsLibrary alloc] init] writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:nil];
[self processImage:[UIImage imageWithData:imageData]];
}
}];
});
}
なぜこれが起こるのでしょうか?