【问题标题】:camera.activeFormat not getting appliedcamera.activeFormat 没有被应用
【发布时间】:2019-04-23 13:33:52
【问题描述】:

我们正在尝试在我们的 iOS 应用程序(用 Objective-C 编写)中设置特定的相机帧分辨率,这在 AVCaptureSessionPreset 中没有定义。通过以下代码,我们想将框架尺寸设置为特定宽度:

  for ( AVCaptureDeviceFormat *format in [self.camera formats] ) {
    NSLog(@"%@", format);
    CMVideoDimensions dim = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
    if(dim.width == 3264){
      if ([ self.camera lockForConfiguration:NULL] == YES) {
        self.camera.activeFormat = format;
        [ self.camera unlockForConfiguration];
      }

    }
  }

但是分辨率设置为 1920x1080 - 我猜这是默认值?是否有定义何时调用相机配置的特定顺序?

【问题讨论】:

    标签: ios objective-c camera avcapturesession avcapturedevice


    【解决方案1】:

    您需要将 AVCaptureSession 的 sessionPreset 属性设置为 AVCaptureSessionPresetInputPriority。 https://developer.apple.com/documentation/avfoundation/avcapturesessionpresetinputpriority?language=objc

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-30
      • 2015-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多