- 初始化BodySkeletonDisplay,用来获取骨架数据并将其传递给openGL ES,openGL ES将渲染数据并在屏幕上显示 。
Public class BodySkeletonDisplay implements BodyRelatedDisplay{//此类需要几个方法//初始化方法public void init(){}//使用OpenGL更新节点数据并绘制 。Public void onDrawFrame(Collection<ARBody> bodies,float[] projectionMatrix){for (ARBody body : bodies) {if (body.getTrackingState() == ARTrackable.TrackingState.TRACKING) {float coordinate = 1.0f;if (body.getCoordinateSystemType() == ARCoordinateSystemType.COORDINATE_SYSTEM_TYPE_3D_CAMERA) {coordinate = DRAW_COORDINATE;}findValidSkeletonPoints(body);updateBodySkeleton();drawBodySkeleton(coordinate, projectionMatrix);}}}//查找有效骨架点private void findValidSkeletonPoints(ARBody arBody) {int index = 0;int[] isExists;int validPointNum = 0;float[] points;float[] skeletonPoints;if (arBody.getCoordinateSystemType() == ARCoordinateSystemType.COORDINATE_SYSTEM_TYPE_3D_CAMERA) {isExists = arBody.getSkeletonPointIsExist3D();points = new float[isExists.length * 3];skeletonPoints = arBody.getSkeletonPoint3D();} else {isExists = arBody.getSkeletonPointIsExist2D();points = new float[isExists.length * 3];skeletonPoints = arBody.getSkeletonPoint2D();}for (int i = 0; i < isExists.length; i++) {if (isExists[i] != 0) {points[index++] = skeletonPoints[3 * i];points[index++] = skeletonPoints[3 * i + 1];points[index++] = skeletonPoints[3 * i + 2];validPointNum++;}}mSkeletonPoints = FloatBuffer.wrap(points);mPointsNum = validPointNum;}}
- 获取骨架点连接数据 , 并将其传递给OpenGL ES以便在屏幕上渲染 。
public class BodySkeletonLineDisplay implements BodyRelatedDisplay {//渲染身体骨骼之间的线条 。public void onDrawFrame(Collection<ARBody> bodies, float[] projectionMatrix) {for (ARBody body : bodies) {if (body.getTrackingState() == ARTrackable.TrackingState.TRACKING) {float coordinate = 1.0f;if (body.getCoordinateSystemType() == ARCoordinateSystemType.COORDINATE_SYSTEM_TYPE_3D_CAMERA) {coordinate = COORDINATE_SYSTEM_TYPE_3D_FLAG;}updateBodySkeletonLineData(body);drawSkeletonLine(coordinate, projectionMatrix);}}}}
8.具体实现请参考:AR Engine示例代码-AR Engine | 华为开发者联盟 (huawei.com)了解更多详情>>
访问华为开发者联盟官网获取开发指导文档华为移动服务开源仓库地址:GitHub、Gitee
关注我们,第一时间了解 HMS Core 最新技术资讯~
【AR人体姿态识别,实现无边界的人机交互】
推荐阅读
- 小米11支持人脸支付吗_小米11支持人脸识别吗
- aws上传文件、删除文件、图像识别
- Object Detection 【YOLOv5】LabVIEW+YOLOv5快速实现实时物体识别含源码
- Object Detection 手把手教你使用LabVIEW OpenCV dnn实现物体识别含源码
- crondtab定时任务%字符无法识别的处理
- 含源码 手把手教你使用LabVIEW OpenCV DNN实现手写数字识别
- 樟木的味道对人体有害吗 樟木味道有害吗
- 如何挑选金丝小枣 如何识别金丝小枣
- 人体特异功能是不是伪科学?
- 如何识别兰花好坏 如何识别兰花好坏?