如何确定ARObjectAnchor已从场景中删除? [英] How to determine that ARObjectAnchor was removed from the scene?

查看:184
本文介绍了如何确定ARObjectAnchor已从场景中删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ARKit验证玩具的位置.我有一个ARObject扫描资源,并且将玩具放置在相机视图中效果很好.换句话说,在将玩具放置在相机视图后的合理时间内,按预期调用了SCNSceneARSessiondidAdddidUpdate.但是,当我将玩具从相机视图移开时,didRemove不会不会被调用,无论是SCNScene还是ARSession都不会被调用.

I am trying to use ARKit for validating the position of a toy. I have an ARObject scan resource, and placing the toy in camera view works pretty well. In other words, didAdd and didUpdate of SCNScene and ARSession are called as expected in a reasonable time after the toy is placed in camera view. But when i move the toy away from the camera view, didRemove does not get called, neither for SCNScene nor for ARSession.

我确实读过关于这种行为的建议,说:"ARKit不知道它是否真的被删除了,可能仍然在指日可待",但这是不切实际的假设.关于此功能的整个Apple文档都是"ARKit可能会自动删除锚点",但没有透露何时以及为什么.我知道 isTracked ,但是ARObjectAnchor似乎是唯一不实现ARTrackable 的ARAnchor子类.

I did read advocations of this behaviour, saying "well ARKit can't know if it was really removed and it still may be just around the corner" but it is rather impractical assumption. The whole Apple documentation about this function is "ARKit may automatically remove anchors" but doesn't say a word about when and why. I know about isTracked but ARObjectAnchor seems to be the only ARAnchor subclass that does not implement ARTrackable.

我能想到的唯一的绝望技巧是didUpdate停止被调用时的某种模糊超时,因为这是删除对象AFAIK的唯一效果.我是否忽略了ARWorldTrackingConfiguration中的某些内容?好吗?

The only desperate hack i can think of is some kind of fuzzy timeout for when didUpdate stops getting called, because that's the only effect of removing the object AFAIK. Did i overlook something in ARWorldTrackingConfiguration? Please?

推荐答案

Apple TSI的信息解释(如果有人想在自己的TSI中引用此问题,请输入id 731233593):

Interpretation of informations from Apple TSI (id 731233593 if anyone wants to refer to this issue in his own TSI):

ARObjectAnchors. 这不是应该依赖的行为.这适用于AR(SCNView|Session)Delegate.didRemove回调和ARFrame.anchors的内容.只有在客户端代码以编程方式删除了相关锚点的情况下,才肯定调用回调.尽管明确询问,但我无法对官方文档"ARKit可能会自动删除锚点"进行更好的解释. "您不必担心为什么会发生这种情况."

ARObjectAnchors are not necessarily removed when the object goes offscreen. It is not a behaviour that should be relied on. This applies to AR(SCNView|Session)Delegate.didRemove callbacks and to the content of ARFrame.anchors. The callbacks are definitely called only if the client code removes the relevant anchor programmatically. I was unable to squeeze a better explanation of the official doc line "ARKit may automatically remove anchors" despite asking explicitly. "You shouldn’t worry about why this happened."

didAdddidUpdate回调进行定时是一种正式方法.证据是用于创建对象扫描的Apple官方项目,文件Controllers/TestRun.swift方法startNoDetectionTimer.使用5秒钟的超时时间.

Timing out on didAdd or didUpdate callbacks is an official method. The evidence is Apple's official project for creating object scans, file Controllers/TestRun.swift method startNoDetectionTimer. Using 5 seconds timeout.

实施ARTrackable的需求ARObjectAnchor反馈助手上填写增强功能请求.我个人受到鼓励去研究替代方法,并发现CoreML出乎意料地友好,并且更适合我的用例.

Demands of ARObjectAnchor to implement ARTrackable are encouraged to fill an enhancement request at Feedback Assistant. I personally was encouraged to investigate alternatives and found that CoreML is unexpectedly friendly and fits my use case much better.

感谢@Andy推动我走了这么远.

Thanks @Andy for pushing me this far.

这篇关于如何确定ARObjectAnchor已从场景中删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆