AVCaptureSession接收内存警告问题

时间:2014-02-23 18:29:51

标签: ios objective-c memory-warning

我使用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]];
            }
        }];
    });
}

为什么会发生这种情况的任何想法?

0 个答案:

没有答案