- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
Apple 最近向 CIDetector
类添加了一个名为 CIDetectorTracking
的新常量,它似乎能够跟踪视频帧之间的面部。如果我能弄清楚它是如何工作的,这对我来说将是非常有益的。
我已经尝试使用我能想到的远程相关的每个对象将此键添加到检测器选项字典中,包括我的 AVCaptureStillImageOutput 实例、我正在处理的 UIImage、YES、1 等。
NSDictionary *detectorOptions = [[NSDictionary alloc] initWithObjectsAndKeys:CIDetectorAccuracyHigh, CIDetectorAccuracy,myAVCaptureStillImageOutput,CIDetectorTracking, nil];
但无论我尝试传递什么参数,它要么崩溃(显然我在这里猜测)要么调试器输出:
Unknown CIDetectorTracking specified. Ignoring.
通常情况下,我不会对此进行猜测,但关于该主题的资源几乎不存在。 Apple's class reference状态:
A key used to enable or disable face tracking for the detector. Use this option when you want to track faces across frames in a video.
除了可用性是 iOS 6+ 和 OS X 10.8+ 之外就是这样。
CIDetector.h
中的注释:
/*The key in the options dictionary used to specify that feature tracking should be used. */
如果这还不够糟糕,Google搜索提供 7 个结果(当他们找到这篇文章时为 8 个)所有这些都是 Apple 类引用、API 差异、询问如何在 iOS 5 中实现此目的的 SO 帖子,或前者的第 3 方副本。
综上所述,我们将不胜感激有关正确使用 CIDetectorTracking
的任何提示或技巧!
最佳答案
你是对的,这个 key 没有很好的文档记录。除了 API 文档之外,它也不在以下内容中进行了解释:
我为 CIDetectorTracking
尝试了不同的值,唯一接受的值似乎是 @(YES)
和 @(NO)
。使用其他值,它会在控制台中打印此消息:
Unknown CIDetectorTracking specified. Ignoring.
当您将该值设置为 @(YES)
时,您应该获得具有检测到的面部特征的跟踪 ID。
但是,当您想要检测从相机捕获的内容中的人脸时,您应该更喜欢 AVFoundation 中的人脸检测 API。它内置面部跟踪,面部检测在 GPU 的后台进行,比 CoreImage 面部检测快得多它需要 iOS 6 和至少 iPhone 4S 或 iPad 2。
面部作为元数据对象 (AVMetadataFaceObject
) 发送到 AVCaptureMetadataOutputObjectsDelegate
。
您可以使用此代码(取自 StacheCam 2 和上述 WWDC session 的幻灯片)设置人脸检测并获取人脸元数据对象:
- (void) setupAVFoundationFaceDetection
{
self.metadataOutput = [AVCaptureMetadataOutput new];
if ( ! [self.session canAddOutput:self.metadataOutput] ) {
return;
}
// Metadata processing will be fast, and mostly updating UI which should be done on the main thread
// So just use the main dispatch queue instead of creating a separate one
// (compare this to the expensive CoreImage face detection, done on a separate queue)
[self.metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
[self.session addOutput:self.metadataOutput];
if ( ! [self.metadataOutput.availableMetadataObjectTypes containsObject:AVMetadataObjectTypeFace] ) {
// face detection isn't supported (via AV Foundation), fall back to CoreImage
return;
}
// We only want faces, if we don't set this we would detect everything available
// (some objects may be expensive to detect, so best form is to select only what you need)
self.metadataOutput.metadataObjectTypes = @[ AVMetadataObjectTypeFace ];
}
// AVCaptureMetadataOutputObjectsDelegate
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputMetadataObjects:(NSArray *)metadataObjects
fromConnection:(AVCaptureConnection *)c
{
for ( AVMetadataObject *object in metadataObjects ) {
if ( [[object type] isEqual:AVMetadataObjectTypeFace] ) {
AVMetadataFaceObject* face = (AVMetadataFaceObject*)object;
CMTime timestamp = [face time];
CGRect faceRectangle = [face bounds];
NSInteger faceID = [face faceID];
CGFloat rollAngle = [face rollAngle];
CGFloat yawAngle = [face yawAngle];
NSNumber* faceID = @(face.faceID); // use this id for tracking
// Do interesting things with this face
}
}
如果要在预览图层中显示人脸框,需要获取转换后的人脸对象:
AVMetadataFaceObject * adjusted = (AVMetadataFaceObject*)[self.previewLayer transformedMetadataObjectForMetadataObject:face];
有关详细信息,请查看 sample code from WWDC 2012 .
关于objective-c - 正确使用 CIDetectorTracking,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13475387/
我遵循了一本名为“Sitepoint Full Stack Javascript with MEAN”的书中的教程,我刚刚完成了第 6 章,应该已经创建了一个带有“数据库”的“服务器”。数据库只不过是
在 Jquery 中,我创建两个数组,一个嵌入另一个数组,就像这样...... arrayOne = [{name:'a',value:1}, {name:'b',value:2}] var arra
这个问题在这里已经有了答案: What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wa
我被放在别人的代码上,有一个类用作其他组件的基础。当我尝试 ng serve --aot(或 build --prod)时,我得到以下信息。 @Component({ ...,
我正在测试一些代码,并使用数据创建了一个 json 文件。 问题是我在警报中收到“[object Object],[object Object]”。没有数据。 我做错了什么? 这是代码:
我想打印 [object Object],[object Object] 以明智地 "[[{ 'x': '1', 'y': '0' }, { 'x': '2', 'y': '1' }]]"; 在 ja
我有一个功能 View ,我正在尝试以特殊格式的方式输出。但我无法让列表功能正常工作。 我得到的唯一返回是[object Object][object Object] [object Object]
在使用优秀的 Sim.js 和 Three.js 库处理 WebGL 项目时,我偶然发现了下一个问题: 一路走来,它使用了 THREE.Ray 的下一个构造函数: var ray = new THRE
我正在使用 Material UI 进行多重选择。这是我的代码。 {listStates.map(col => (
我的代码使用ajax: $("#keyword").keyup(function() { var keyword = $("#keyword").val(); if (keyword.
我遇到了下一个错误,无法理解如何解决它。 Can't resolve all parameters for AuthenticationService: ([object Object], ?, [o
我正在尝试创建一个显示动态复选框的表单,至少应选中其中一个才能继续。我还需要获取一组选中的复选框。 这是组件的代码: import { Component, OnInit } from '@angul
我正在开发 NodeJs 应用程序,它是博客应用程序。我使用了快速验证器,我尝试在 UI 端使用快速闪存消息将帖子保存在数据库中之前使用闪存消息验证数据,我成功地将数据保存在数据库中,但在提交表单后消
我知道有些人问了同样的问题并得到了解答。我已经查看了所有这些,但仍然无法解决我的问题。我有一个 jquery snipet,它将值发送到处理程序,处理程序处理来自 JS 的值并将数据作为 JSON 数
我继承了一个非常草率的项目,我的任务是解释为什么它不好。我注意到他们在整个代码中都进行了这样的比较 (IQueryable).FirstOrDefault(x => x.Facility == fac
我只是在删除数组中的对象时偶然发现了这一点。 代码如下: friends = []; friends.push( { a: 'Nexus', b: 'Muffi
这两个代码片段有什么区别: object = nil; [object release] 对比 [object release]; object = nil; 哪个是最佳实践? 最佳答案 object
我应该为其他人将从中继承的第一个父对象传递哪个参数,哪个参数更有效 Object.create(Object.prototype) Object.create(Object) Object.creat
我在不同的对象上安排不同的选择器 [self performSelector:@selector(doSmth) withObject:objectA afterDelay:1]; [self per
NSLog(@"%p", &object); 和 NSLog(@"%p", object); 有什么区别? 两者似乎都打印出一个内存地址,但我不确定哪个是对象的实际内存地址。 最佳答案 这就是我喜欢的
我是一名优秀的程序员,十分优秀!