4

AVCamDemo静止画だけをキャプチャして実験できるように、プロジェクトを合理化しています。

captureStillImage()以下は、メソッドの新しいコードです。

- (void) captureStillImage
{
    AVCaptureConnection *stillImageConnection = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];
    if ([stillImageConnection isVideoOrientationSupported]) {
        [stillImageConnection setVideoOrientation:orientation];
    }
    [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:stillImageConnection
                completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
NSLog(@"In the completionHandler block");
           if (imageDataSampleBuffer != NULL) {
               NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
               UIImage *image = [[UIImage alloc] initWithData:imageData];
                     [self writeImageFile:image];
                     [image release];
            }
          if ([[self delegate] respondsToSelector:@selector(captureManagerStillImageCaptured:)]) {
               [[self delegate] captureManagerStillImageCaptured:self];
                }
     }];
NSLog(@"exiting....");
}

私のテストでは、ブロック内の NSLog ステートメントが実行されないことがあり、そのため、 stillImageファイルが保存されないことがわかりました。

タイミングの問題が発生していますか? もしそうなら、どのように対処すればよいですか?

ありがとう、そしてよろしく。サム。

4

0 に答える 0