如何从ARbodyAnchor获取人体高度?

发布于 2025-01-11 03:26:45 字数 560 浏览 0 评论 0原文

我正在尝试从 ARBodyAnchor 获取真实世界的人体高度。我知道我可以获得身体关节之间的真实距离。例如,臀部到脚关节,如下面的代码所示。但是如何获得从头顶到脚底的距离呢?

func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
    if anchor is ARBodyAnchor {
        let footIndex = ARSkeletonDefinition.defaultBody3D.index(for: .leftFoot)
        let footTransform = ARSkeletonDefinition.defaultBody3D.neutralBodySkeleton3D!.jointModelTransforms[footIndex]
        let distanceFromHipOnY = abs(footTransform.columns.3.y)
        print(distanceFromHipOnY)
    }
}

I am trying to get real-world human body height from ARBodyAnchor. I understand that I can get real-world distance between body joints. For example hip to foot-joint as in code below. But how do I get distance from top of head to bottom of foot?

func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
    if anchor is ARBodyAnchor {
        let footIndex = ARSkeletonDefinition.defaultBody3D.index(for: .leftFoot)
        let footTransform = ARSkeletonDefinition.defaultBody3D.neutralBodySkeleton3D!.jointModelTransforms[footIndex]
        let distanceFromHipOnY = abs(footTransform.columns.3.y)
        print(distanceFromHipOnY)
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神经暖 2025-01-18 03:26:46

如果您需要设置自定义模型,请阅读这篇文章 MoCap 模型。

输入图片这里的描述

ARSkeleton3D的默认高度来自right_toes_joint(或者如果您愿意) left_toes_joint)到 head_joint 的距离为 1.71 米。由于 Apple 骨骼系统定义中的 head_joint 是最上面的骨骼点,因此您可以使用常见头骨的高度 - 从眼线到头顶

换句话说,虚拟模型骨架中从neck_3_jointhead_joint的距离与从head_jointcrown的距离大致相同>。

输入图片这里的描述

ARSkeleton3D 中有 91 个关节:

print(bodyAnchor.skeleton.jointModelTransforms.count)      // 91

代码:

extension ViewController: ARSessionDelegate {

    func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
    
        for anchor in anchors {
        
            guard let bodyAnchor = anchor as? ARBodyAnchor
            else { return }

            let skeleton = bodyAnchor.skeleton

            for (i, joint) in skeleton.definition.jointNames.enumerated() {
                print(i, joint)

                // [10] right_toes_joint
                // [51] head_joint
            }
        
            let toesJointPos = skeleton.jointModelTransforms[10].columns.3.y
            let headJointPos = skeleton.jointModelTransforms[51].columns.3.y

            print(headJointPos - toesJointPos)       // 1.6570237 m
        }
    }
}

但是,我们有一个补偿器:

bodyAnchor.estimatedScaleFactor

ARKit 必须知道摄像头中人的高度,才能估计人的身体锚点的准确世界位置。 ARKit 使用estimatedScaleFactor 的值来校正身体锚点在物理环境中的位置。

默认的现实世界身体高度为 1.8 米。 (某种不匹配...)

estimatedScaleFactor 的默认值为 1.0。

如果您设置:

let config = ARBodyTrackingConfiguration()
config.automaticSkeletonScaleEstimationEnabled = true
arView.session.run(config, options: [])

ARKit 会将此属性设置为 0.0 到 1.0 之间的值。

Read this post if you need to setup a custom model for MoCap.

enter image description here

The default height of ARSkeleton3D from right_toes_joint (or if you wish left_toes_joint) to head_joint is 1.71 meters. And since head_joint in Apple's skeletal system's definition is the upmost skeleton's point, you can use the common skull's height – from eye line to crown.

In other words, the distance from neck_3_joint to head_joint in virtual model's skeleton is approximately the same as from head_joint to crown.

enter image description here

There are 91 joint in ARSkeleton3D:

print(bodyAnchor.skeleton.jointModelTransforms.count)      // 91

Code:

extension ViewController: ARSessionDelegate {

    func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
    
        for anchor in anchors {
        
            guard let bodyAnchor = anchor as? ARBodyAnchor
            else { return }

            let skeleton = bodyAnchor.skeleton

            for (i, joint) in skeleton.definition.jointNames.enumerated() {
                print(i, joint)

                // [10] right_toes_joint
                // [51] head_joint
            }
        
            let toesJointPos = skeleton.jointModelTransforms[10].columns.3.y
            let headJointPos = skeleton.jointModelTransforms[51].columns.3.y

            print(headJointPos - toesJointPos)       // 1.6570237 m
        }
    }
}

However, we have a compensator:

bodyAnchor.estimatedScaleFactor

ARKit must know the height of a person in the camera feed to estimate an accurate world position for the person's body anchor. ARKit uses the value of estimatedScaleFactor to correct the body anchor's position in the physical environment.

The default real-world body is 1.8 meters tall. (some kind of mismatch...)

The default value of estimatedScaleFactor is 1.0.

If you set:

let config = ARBodyTrackingConfiguration()
config.automaticSkeletonScaleEstimationEnabled = true
arView.session.run(config, options: [])

ARKit sets this property to a value between 0.0 and 1.0.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文