4

iPad 内に小さなプレビュー エリアを持つカスタム カメラを作成していますが、そのプレビューのストリームは時計回りに回転します。

Apple の AVCam デモと SquareCam デモの両方を見ましたが、どちらにも解決策がありません。StackOverflow のすべての AVFoundation オリエンテーション スレッドは、特に入力方向ではなく、出力方向について話しています。

私が使用しているセッションコードは次のとおりです。

AVCaptureDevice *frontalCamera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    _session = [[AVCaptureSession alloc] init];
    [_session beginConfiguration];
    NSError *error;
    AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:frontalCamera error:&error];
    [_session addInput:input];
    _output = [[AVCaptureStillImageOutput alloc] init];
    [_output setOutputSettings:[[NSDictionary alloc] initWithObjectsAndKeys:AVVideoCodecJPEG,AVVideoCodecKey,nil]];
    [_session addOutput:_output];
    AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:_session];
    previewLayer.frame = self.imageViewCamera.bounds;
    previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
    [self.imageViewCamera.layer addSublayer:previewLayer];
    _session.sessionPreset = AVCaptureSessionPreset640x480;
    [_session commitConfiguration];
    [_session startRunning];

どんな助けでも大歓迎です!

4

3 に答える 3

2

iOS 6 の Apple ドキュメントには、videoOrientation (AVCaptureConnection)代わりに使用するように書かれています。

于 2013-04-26T02:10:23.340 に答える
1

これは非推奨になりましたが、previewLayerの方向を反時計回りに変更できます。

previewLayer.orientation = AVCaptureVideoOrientationLandscapeRight;

ただし、非推奨ではないソリューションが何であるかはわかりません。

于 2012-12-04T22:47:36.820 に答える
1

レイヤーの向き。(iOS 6.0 では非推奨。代わりにvideoOrientation (AVCaptureConnection) を使用してください。)

だから使用:

[[AVCaptureVideoPreviewLayer connection] setVideoOrientation: AVCaptureVideoOrientationLandscapeRight];

また

AVCaptureVideoPreviewLayer.connection.videoOrientation= AVCaptureVideoOrientationLandscapeRight;
于 2014-06-26T08:01:58.903 に答える