gpt4 book ai didi

ios - CaptureOutput 委托(delegate)函数以与 AVCaptureDevice 的帧速率一样快的速度运行

转载 作者:搜寻专家 更新时间:2023-11-01 07:11:24 26 4
gpt4 key购买 nike

目前我有一个带有 AVCaptureVideoDataOutput 的 AVCaptureSession。据我了解,每次相机捕获帧时都会调用 captureOutput 委托(delegate)函数。默认情况下,captureOutput 函数以 30fps 的速度调用。

我还有一个 CMMotionManager 在手机移动时存储数据。运动管理器以大约 90-100fps 的速度运行。

无论如何,我是否可以增加相机在帧中拍摄的 fps,以便以与 motionManager 大致相同的速度调用 captureOutput 函数?

如有任何帮助,我们将不胜感激。

最佳答案

来自苹果 docs

The following code example illustrates how to select an iOS device’s highest possible frame rate

- (void)configureCameraForHighestFrameRate:(AVCaptureDevice *)device
{
AVCaptureDeviceFormat *bestFormat = nil;
AVFrameRateRange *bestFrameRateRange = nil;
for ( AVCaptureDeviceFormat *format in [device formats] ) {
for ( AVFrameRateRange *range in format.videoSupportedFrameRateRanges ) {
if ( range.maxFrameRate > bestFrameRateRange.maxFrameRate ) {
bestFormat = format;
bestFrameRateRange = range;
}
}
}
if ( bestFormat ) {
if ( [device lockForConfiguration:NULL] == YES ) {
device.activeFormat = bestFormat;
device.activeVideoMinFrameDuration = bestFrameRateRange.minFrameDuration;
device.activeVideoMaxFrameDuration = bestFrameRateRange.minFrameDuration;
[device unlockForConfiguration];
}
}
}

关于ios - CaptureOutput 委托(delegate)函数以与 AVCaptureDevice 的帧速率一样快的速度运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44704391/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com