- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个 iOS 应用,它使用手机的前置摄像头并设置 AVCaptureSession 来读取传入的摄像头数据。我设置了一个简单的帧计数器来检查数据传入的速度,令我惊讶的是,当相机处于低光照条件下时,帧速率(使用代码中的 imagecount 变量测量)非常慢,但是一旦我移动 Handlebars 机放到明亮的地方帧率几乎会增加三倍。我想在整个过程中保持图像处理的高帧率,并将 minFrameDuration 变量设置为 30 fps,但这没有帮助。关于为什么会出现这种随机行为的任何想法?
创建捕获 session 的代码如下:
#pragma mark Create and configure a capture session and start it running
- (void)setupCaptureSession
{
NSError *error = nil;
// Create the session
session = [[AVCaptureSession alloc] init];
// Configure the session to produce lower resolution video frames, if your
// processing algorithm can cope. We'll specify medium quality for the
// chosen device.
session.sessionPreset = AVCaptureSessionPresetLow;
// Find a suitable AVCaptureDevice
//AVCaptureDevice *device=[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSArray *devices = [AVCaptureDevice devices];
AVCaptureDevice *frontCamera;
AVCaptureDevice *backCamera;
for (AVCaptureDevice *device in devices) {
if ([device hasMediaType:AVMediaTypeVideo]) {
if ([device position] == AVCaptureDevicePositionFront) {
backCamera = device;
}
else {
frontCamera = device;
}
}
}
//Create a device input with the device and add it to the session.
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:backCamera
error:&error];
if (!input) {
//Handling the error appropriately.
}
[session addInput:input];
// Create a VideoDataOutput and add it to the session
AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
[session addOutput:output];
// Configure your output.
dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);
// Specify the pixel format
output.videoSettings =
[NSDictionary dictionaryWithObject:
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA]
forKey:(id)kCVPixelBufferPixelFormatTypeKey];
// If you wish to cap the frame rate to a known value, such as 30 fps, set
// minFrameDuration.
output.minFrameDuration = CMTimeMake(1,30);
//Start the session running to start the flow of data
[session startRunning];
}
#pragma mark Delegate routine that is called when a sample buffer was written
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
//counter to track frame rate
imagecount++;
//display to help see speed of images being processed on ios app
NSString *recognized = [[NSString alloc] initWithFormat:@"IMG COUNT - %d",imagecount];
[self performSelectorOnMainThread:@selector(debuggingText:) withObject:recognized waitUntilDone:YES];
}
最佳答案
当光线较少时,相机需要更长的曝光时间才能在每个像素中获得相同的信噪比。这就是为什么您可能期望帧速率在低光照条件下下降。
您将 minFrameDuration 设置为 1/30 秒,以试图防止长时间曝光帧降低帧速率。但是,您应该改为设置 maxFrameDuration:您的代码原样表示帧速率不超过 30 FPS,但它可能是 10 FPS 或 1 FPS....
此外,the Documentation说用 lockForConfiguration: 和 unlockForConfiguration: 括起对这些参数的任何更改,所以可能是您的更改没有被采用。
关于iOS 应用程序视频捕捉在低光下变慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20385585/
我有一个 OGre3D+Hikari 应用程序,我想在其背景中循环使用 flash 动画。 我尝试调整 createFlashOverlay 中的一些参数(特别是 zorder 和层),但没有任何改变
奇怪的问题,但只是在寻找指导或建议。我的网络应用程序具有协助运算符(operator)计时的功能。我的任务是从 mysql php 触发器打开红色闪光灯(警灯)? 可以这样做吗,因为我认为网站无法与我
我对 WIX 相当陌生,所以如果我完全错过了这里的船,请原谅我,但我想知道是否可以在 wxs 文件中重用组件(mwm、cab 等)而无需重新链接它们每次。我正在使用的安装程序有几个可执行文件、dll
我喜欢 MVVM Light 的 Messenger 及其灵 active ,但是当我忘记显式注销收件人时(在 Silverlight 4 中),我遇到了内存泄漏问题。 原因解释here ,但我对此表
当我在 Visual Studio 2010 中安装 MVVM Light v3.xx 后,我有许多用于创建 MVVM 项目的模板。 但我需要全新安装 Visual Studio,在这种情况下我安装了
我刚开始使用 libgdx 创建游戏。这是一个使用 scene2d ui 的自上而下的 2d 射击游戏。现在我想,我可以在某些层面上添加黑暗和光明,但我不想使用 box2d 重写所有内容。我不需要逼真
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我正在尝试将我的 Windows Phone 8 Silverlight 应用程序转换为 8.1 Phone 应用程序作为通用应用程序的一部分。我不知道这是否相关,因为这是我第一次尝试正确实现 Vie
我收到以下消息,在 Spring Cloud 数据流中运行任务。 DEBUG 13167 --- [spring_batch146] com.zaxxer.hikari.pool.HikariPool
我使用带有中继器控件的 jQuery Light Slider 来显示数据库中的图像,如下所示: '> ' run
我熟悉 MVVM Light 工具包的 ViewModelBase、Message,但不熟悉 ViewModelLocator。在我的应用程序中有 Singleton ViewModel,例如 Pri
我是 MVVM 的新手,所以如果这个问题有一个简单的答案,我深表歉意,但我无法通过搜索 Google 来解决这个问题。 所以,基本上,我正在使用 MVVM Light 制作 Windows 10 通用
我已经创建了我的第一个 MVVMLight 项目,我有一个问题: 我有一个按钮,上面绑定(bind)了一个命令。当命令执行时,在不同的用例中,我必须向最终用户获取/提供信息,例如: 如果项目是新的,询
我正在通过播放框架和 mariadb 客户端使用 hikari 池连接,因为我已经定期更新它们(播放 2.6.5 -> 2.6.6 和 mariadb 2.1.1 -> 2.1.2 但不确定它是否相关
关于如何在 ViewModel 中定义一个 RelayCommand 有几个例子: 选项 1(惰性): /// /// Gets the LogOnCommand. /// /// The Log
我正在处理一个示例 MVVM Light 项目并正在实现 SimpleIoc ViewModelLocator。我已经能够构建一个 IRepositoryService,它从数据库(即公司、员工等)中
我们在 Windows 8.1 中有一个与 Win 10 兼容的工作项目。现在的要求是将此项目转换为 UWP。在早期的项目中,我们使用了 PRISM 作为 MVVM 的框架。现在的问题是,对于UWP应
在the latest release of MVVM Light note ,已表明 MVVM Light 现在提供“导航服务”。 但是我自己和我 friend google都找不到怎么用。 我可以
我是一名优秀的程序员,十分优秀!