提问人:Konstantin Kuchenmeister 提问时间:6/13/2022 更新时间:6/13/2022 访问量:173
如何将 3D 关节点(变换)投影到 2D 屏幕 ARKit 上?
How to project 3D Joint Points (Transformation) onto 2D Screen ARKit?
问:
我正在尝试使用 ARKit 将 3D 人体关节点投影到 iPhone 的屏幕上。
- 我正在提取全局转换:
let rightArmPosition = skeleton.modelTransform(for: ARSkeleton.JointName(rawValue: "right_arm_joint"))!
let rootPosition = skeleton.modelTransform(for: .root)!
- 我正在计算偏移量
let rightOffset = simd_make_float3(rightArmPosition.columns.3)
let rootOffset = simd_make_float3(rootPosition.columns.3)
- 我正在预测要点
let pMatrix = camera.projectionMatrix
let pRightOffset = camera.projectPoint(rightOffset, orientation: .portrait, viewportSize: CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
let pRootOffset = camera.projectPoint(rootOffset, orientation: .portrait, viewportSize: CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
humanJointsView.frame = UIScreen.main.bounds
humanJointsView.points = [pRightOffset, pRootOffset]
- 我正在尝试在目标视图中绘制点:
override func draw(_ rect: CGRect) {
path.removeAllPoints()
self.points.forEach { point in
path = UIBezierPath(ovalIn: CGRect(x: point.x, y: point.y, width: CGFloat(30), height: CGFloat(30)))
UIColor.green.setFill()
path.fill()
}
}
但是这种方法不起作用,我的错误在哪里?
谢谢!
答:
0赞
Reza Hemadi
6/13/2022
#1
右臂和根变换在骨架模型空间中,您需要将它们与主体锚变换相乘。
rightArmWorldTransform = body.transform * rightArmPosition
评论