Error retrieving memory with AVCaptureSession

I built my own custom camera class using AVCaptureSession and a lot of code from the Apple AVCam demo application. Basically, the function that I use to capture my image is verbatim from the Apple application, however, when I take a picture, I get a warning about the received memory in the console. This does not always happen, but almost always in the first picture. This is the code that is my problem.

- (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]];
            }
        }];
    });
}

Any ideas why this is happening?

+3
source share

All Articles