ARSession未运行

2022-01-27 19:09:04 标签 iosobjective-carkit

(ARSession *)session didUpdateAnchors:(NSArray<__kindof ARAnchor *>*)锚和- (void)会话:(ARSession *)会话didUpdateFrame:(ARFrame *)帧

代码如下:

@interface LVARFaceTracker ()<ARSessionDelegate>
@property (nonatomic, strong) ARSession *session;
@property (nonatomic, strong) NSDictionary<ARBlendShapeLocation, NSNumber*> *blendShapes;
@end
@implementation LVARFaceTracker
- (instancetype)init
{
    if (!ARFaceTrackingConfiguration.isSupported) {
        return nil;
    }
    self = [super init];
    if (self) {
        _session = [[ARSession alloc] init];
        _session.delegate = self;
    }
    return self;
}
- (void)start {
    ARFaceTrackingConfiguration *configuration = [[ARFaceTrackingConfiguration alloc] init];
    if (@available(iOS 13.0, *)) {
        configuration.maximumNumberOfTrackedFaces = ARFaceTrackingConfiguration.supportedNumberOfTrackedFaces;
    }
    configuration.lightEstimationEnabled = true;
    [_session runWithConfiguration:configuration options:ARSessionRunOptionResetTracking|ARSessionRunOptionRemoveExistingAnchors];
}
- (void)session:(ARSession *)session didUpdateAnchors:(NSArray<__kindof ARAnchor *> *)anchors {
    static NSInteger count = 0;
    LVLogDev(gTag, @"%zd", count++);
    ARAnchor *anchor = anchors.firstObject;
    if (![anchor isKindOfClass:ARFaceAnchor.class]) {
        return;
    }
    ARFaceAnchor *faceAnchor = (ARFaceAnchor *)anchor;
    self.blendShapes = faceAnchor.blendShapes;
}
- (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame {
    LVLogDev(gTag, @"didUpdateFrame");
}
@end

输出日志如下:

2021-08-17 15:58:02.675377+0800 Line:60, didUpdateFrame
2021-08-17 15:58:02.675462+0800 Line:60, didUpdateFrame
2021-08-17 15:58:02.675519+0800 Line:60, didUpdateFrame
2021-08-17 15:58:02.678206+0800 Line:60, didUpdateFrame
2021-08-17 15:58:02.740027+0800 Line:49, 0
2021-08-17 15:58:02.740492+0800 Line:60, didUpdateFrame
2021-08-17 15:58:02.754142+0800 Line:49, 1
2021-08-17 15:58:02.754299+0800 Line:60, didUpdateFrame
2021-08-17 15:58:02.855339+0800 Line:49, 2
2021-08-17 15:58:02.855509+0800 Line:60, didUpdateFrame
2021-08-17 15:58:02.928421+0800 Line:49, 3
2021-08-17 15:58:02.928537+0800 Line:60, didUpdateFrame
2021-08-17 15:58:02.991699+0800 Line:49, 4
2021-08-17 15:58:02.992058+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.024641+0800 Line:49, 5
2021-08-17 15:58:03.024745+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.041826+0800 Line:49, 6
2021-08-17 15:58:03.041936+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.058302+0800 Line:49, 7
2021-08-17 15:58:03.058366+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.074869+0800 Line:49, 8
2021-08-17 15:58:03.074937+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.091447+0800 Line:49, 9
2021-08-17 15:58:03.091497+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.108459+0800 Line:49, 10
2021-08-17 15:58:03.108529+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.187390+0800 Line:49, 11
2021-08-17 15:58:03.187462+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.242562+0800 Line:49, 12
2021-08-17 15:58:03.242662+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.259915+0800 Line:49, 13
2021-08-17 15:58:03.260350+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.276379+0800 Line:49, 14
2021-08-17 15:58:03.276456+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.291067+0800 Line:49, 15
2021-08-17 15:58:03.291187+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.308161+0800 Line:49, 16
2021-08-17 15:58:03.308242+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.324790+0800 Line:49, 17
2021-08-17 15:58:03.324844+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.341743+0800 Line:49, 18
2021-08-17 15:58:03.341805+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.357710+0800 Line:49, 19
2021-08-17 15:58:03.357770+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.374968+0800 Line:49, 20
2021-08-17 15:58:03.375030+0800 Line:60, didUpdateFrame
2021-08-17 15:58:03.391587+0800 Line:49, 21
2021-08-17 15:58:03.391642+0800 Line:60, didUpdateFrame

只回了21次就不再回了

阅读全文

▼ 版权说明

相关文章也很精彩
推荐内容
更多标签
相关热门
全站排行
随便看看

错说 cuoshuo.com —— 程序员的报错记录

部分内容根据CC版权协议转载;网站内容仅供参考,生产环境使用务必查阅官方文档

辽ICP备19011660号-5

×

扫码关注公众号:职场神器
发送: 1
获取永久解锁本站全部文章的验证码