相关疑难解决方法(0)

AVFoundation图像方向在预览中偏离90度,但在相机胶卷中很好

发生了一些非常奇怪的事情,我正在尝试使用AVFoundation捕获图像,相机滚动图像看起来很好,但图像预览将图像旋转了90度.

这是我用来捕获图像的代码

AVCaptureConnection *videoConnection = nil;
for (AVCaptureConnection *connection in stillImageOutput.connections)
{
    for (AVCaptureInputPort *port in [connection inputPorts])
    {
        if ([[port mediaType] isEqual:AVMediaTypeVideo] )
        {
            videoConnection = connection;
            break;
        }
    }
    if (videoConnection)
    {
        break;
    }
}

//NSLog(@"about to request a capture from: %@", stillImageOutput);
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
 {
     CFDictionaryRef exifAttachments = CMGetAttachment( imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
     if (exifAttachments)
     {
         // Do something with the attachments.
         //NSLog(@"attachements: %@", exifAttachments);
     } else {
         NSLog(@"no attachments");
     }

     NSData *imageData …
Run Code Online (Sandbox Code Playgroud)

avfoundation ios

12
推荐指数
1
解决办法
8261
查看次数

标签 统计

avfoundation ×1

ios ×1