This answer和其他人解释了当ARKit检测到锚点或平面时如何获得通知,但是当ARKit检测到特征点时如何收到通知?
答案 0 :(得分:1)
查看API,它与您链接的答案有些相似。
使用ARSessionDelegate session(_ session: ARSession, didUpdate frame: ARFrame)
,您可以访问刚刚传入的ARFrame的rawFeaturePoints
。
所以它看起来像:
// Not actually tested
class MyARSessionDelegate: ARSessionDelegate {
var previouslyDetectedPointCount = 0
func session(_ session: ARSession, didUpdate frame: ARFrame) {
// Check if new points are detected
if previouslyDetectedPointCount != frame.rawFeaturePoints?.points.count {
// point count has changed
previouslyDetectedPointCount = frame.rawFeaturePoints!.points.count
}
}
}
虽然至于为什么你想要寻找特定点是好奇的。文件明确指出:
ARKit不保证原始数量和排列 功能点在软件版本之间保持稳定,甚至是 在同一会话中的后续帧之间。
答案 1 :(得分:0)
这似乎不是理想的解决方案,但它确实有效。从func session(_ session: ARSession, didUpdate frame: ARFrame)
协议实施ARSessionDelegate
功能,并检查每个帧中的功能点。
func session(_ session: ARSession, didUpdate frame: ARFrame) {
// Show tap icon once we find feature points
if !detectedFeaturePoints, let points = frame.rawFeaturePoints?.points, let firstPoint = points.first {
detectedFeaturePoints = true
}
}