【问题标题】:Check iOS capture resolution of camera检查相机的iOS捕获分辨率
【发布时间】:2014-07-31 21:13:17
【问题描述】:

我在 iOS 7 上使用 OpenGL 将前置摄像头视频捕获渲染到 UIView 在 iPhone 显示屏上(相同的 iphone 5)。我正在使用AVCaptureSessionPreset640x480 并将其传递给AVCaptureSession 方法

[captureSession setSessionPreset:AVCaptureSessionPreset640x480];

但是,渲染视频的分辨率似乎低于上述设置, 好像是AVCaptureSessionPreset352x288。事实上,无论我通过什么常数 从这些没有区别分辨率是相同的

NSString *const AVCaptureSessionPresetPhoto;
NSString *const AVCaptureSessionPresetHigh;
NSString *const AVCaptureSessionPresetMedium;
NSString *const AVCaptureSessionPresetLow;
NSString *const AVCaptureSessionPreset352x288;
NSString *const AVCaptureSessionPreset640x480;
NSString *const AVCaptureSessionPreset1280x720;
NSString *const AVCaptureSessionPreset1920x1080;
NSString *const AVCaptureSessionPresetiFrame960x540;
NSString *const AVCaptureSessionPresetiFrame1280x720;
NSString *const AVCaptureSessionPresetInputPriority;

如何检查相机实际拍摄的分辨率是多少?

谢谢

【问题讨论】:

    标签: ios iphone ios7 avcapturesession


    【解决方案1】:

    读取正在捕获的缓冲区的尺寸,如下(对于AVCaptureSessionPresetPhoto,您当然需要捕获静止图像,而不是读取视频帧...):

    - (void) captureOutput:(AVCaptureOutput *)captureOutput
           didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
                  fromConnection:(AVCaptureConnection *)connection
      {
        CVPixelBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
        CVPixelBufferLockBaseAddress(imageBuffer,0);
        size_t width = CVPixelBufferGetWidth(imageBuffer);
        size_t height = CVPixelBufferGetHeight(imageBuffer);
        CVPixelBufferUnlockBaseAddress(imageBuffer,0);
    
        // "width" and "height" now hold your dimensions...
    
      }
    

    【讨论】:

      猜你喜欢
      • 2010-09-06
      • 2013-10-25
      • 2023-04-04
      • 2016-09-13
      • 2012-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多