0

私はAppleのAVCamソースコードを使用してカスタムカメラを作成していますが、それは魅力のように機能します.問題は、ビデオまたは画像をキャプチャしてフォトライブラリにチェックインすると、向きが横向きに変更されることです(キャプチャしたとしても縦向きにします)。私はこれについて多くのことを検索しましたが、この方法を見つけることができませんでした。何か助けはありますか?

ちなみに、私のアプリは縦向きのみをサポートしており、キャプチャは縦向きでのみ行う必要があります。

アップデート:

AVCaptureConnection *captureConnection = ...
if ([captureConnection isVideoOrientationSupported])
{
    AVCaptureVideoOrientation orientation = AVCaptureVideoOrientationPortrait;
    [captureConnection setVideoOrientation:orientation];
}

これはうまくいきません。

4

1 に答える 1

0

画像をキャプチャするには、向きも設定する必要があります。画像をディスクに保存するときは、使用する必要があります

writeImageToSavedPhotosAlbum:orientation:completionBlock:

機能し、そこにも正しい「方向」パラメーターを設定します。

使用法: https://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/index.html#//apple_ref/occ/instm/ALAssetsLibrary/writeImageToSavedPhotosAlbum:orientation:completionBlock :

Objective C の例:

// Flash set to Auto for Still Capture
    [CameraViewController setFlashMode:AVCaptureFlashModeAuto
                             forDevice:[[self videoDeviceInput] device]];

    // Capture a still image.
    [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo]
                                                         completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {

        if (imageDataSampleBuffer) {
            self.imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];

            [[[ALAssetsLibrary alloc] init] writeImageToSavedPhotosAlbum:image.CGImage
                                                             orientation:(ALAssetOrientation)[image imageOrientation]
                                                         completionBlock:^(NSURL *assetURL, NSError *error) {
                                                             if(error == nil) {
                                                                 NSLog(@"PHOTO SAVED - assetURL: %@", assetURL);
                                                             } else {
                                                                 NSLog(@"ERROR : %@",error);
                                                             }
                                                         }];
于 2014-12-18T14:37:10.777 に答える