DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Allow Users to Track Fitness Status in Your App
  • Turn Your App into a Handy Health Assistant
  • Building a Simple Todo App With Model Context Protocol (MCP)
  • Mastering React App Configuration With Webpack

Trending

  • Simplify Authorization in Ruby on Rails With the Power of Pundit Gem
  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era
  • Comparing SaaS vs. PaaS for Kafka and Flink Data Streaming
  • Scalability 101: How to Build, Measure, and Improve It

How to Develop an AR-Based Health Check App

Learn how to integrate AR Engine into an AR app for your own health.

By 
Jackson Jiang user avatar
Jackson Jiang
DZone Core CORE ·
Apr. 16, 22 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
8.3K Views

Join the DZone community and get the full member experience.

Join For Free

Now that spring has arrived, it's time to get out and stretch your legs! As programmers, many of us are used to being seated for hours and hours at a time, which can lead to back pain and aches. We're all aware that building a workout plan, and keeping track of health indicators around-the-clock, can have enormous benefits for body, mind, and soul. 

Fortunately, AR Engine makes that remarkably easy. It comes with face tracking capabilities, and will soon support body tracking as well. Thanks to core AR algorithms, AR Engine is able to monitor heart rate, respiratory rate, facial health status, and heart rate waveform signals in real-time during your workouts. You can also use it to build an app, for example, to track the real-time workout status, perform real-time health checks for patients, or monitor real-time health indicators of vulnerable users, like the elderly or the disabled. With AR Engine, you can make your health or fitness app more engaging and visually immersive than you might have believed possible. 

Advantages and Device Model Restrictions

  1. Monitors core health indicators like heart rate, respiratory rate, facial health status, and heart rate waveform signals in real-time. 
  2. Enables devices to better understand their users. Thanks to technologies like Simultaneous Localization and Mapping (SLAM) and 3D reconstruction, AR Engine renders images to build 3D human faces on mobile phones, resulting in seamless virtual-physical cohesion. 
  3. Supports all of the device models listed in Software and Hardware Requirements of AR Engine Features. 

Demo Introduction

A simple demo is available to give you a grasp of how to integrate AR Engine, and use its human body and face tracking capabilities. 

  • ENABLE_HEALTH_DEVICE: indicates whether to enable health checks. 
  • HealthParameter: health check parameter, including heart rate, respiratory rate, age and gender probability based on facial features, and heart rate waveform signals. 
  • FaceDetectMode: face detection mode, including health rate checking, respiratory rate checking, real-time health checking, and all of the three above. 

Effect

The following details how you can run the demo using the source code.

Key Steps

1. Add the Huawei Maven repository to the project-level build.gradle file.

Java
 
buildscript {
    repositories {
        maven { url 'http://developer.huawei.com/repo/'}
    }
dependencies {
        ...
        // Add the AppGallery Connect plugin configuration.
        classpath 'com.huawei.agconnect:agcp:1.4.2.300'
    }
}allprojects {
    repositories {
        maven { url 'http://developer.huawei.com/repo/'}
    }
}


2. Add dependencies on the SDK to the app-level build.gradle file. 

Java
 
implementation 'com.huawei.hms:arenginesdk:3.7.0.3'


3. Declare system permissions in the AndroidManifest.xml file. 

Java
 
<uses-permission android:name="android.permission.CAMERA" />


4. Check whether AR Engine has been installed on the current device. If yes, the app can run properly. If not, the app automatically redirects the user to AppGallery to install AR Engine. 

Java
 
boolean isInstallArEngineApk = AREnginesApk.isAREngineApkReady(this);
if (!isInstallArEngineApk && isRemindInstall) {
    Toast.makeText(this, "Please agree to install.", Toast.LENGTH_LONG).show();
    finish();
}
if (!isInstallArEngineApk) {
    startActivity(new Intent(this, ConnectAppMarketActivity.class));
    isRemindInstall = true;
}
return AREnginesApk.isAREngineApkReady(this);

Key Code

1. Call ARFaceTrackingConfig and create an ARSession object. Then, set the human face detection mode, configure AR parameters for motion tracking, and enable motion tracking.

Java
 
mArSession = new ARSession(this);
mArFaceTrackingConfig = new ARFaceTrackingConfig(mArSession);
mArFaceTrackingConfig.setEnableItem(ARConfigBase.ENABLE_HEALTH_DEVICE);
mArFaceTrackingConfig
    .setFaceDetectMode(ARConfigBase.FaceDetectMode.HEALTH_ENABLE_DEFAULT.getEnumValue());


2. Call FaceHealthServiceListener to add your app and pass the health check status and progress. Call handleProcessProgressEvent() to obtain the health check progress. 

Java
 
mArSession.addServiceListener(new FaceHealthServiceListener() {
    @Override
    public void handleEvent(EventObject eventObject) {
        if (!(eventObject instanceof FaceHealthCheckStateEvent)) {
            return;
        }
        final FaceHealthCheckState faceHealthCheckState =
            ((FaceHealthCheckStateEvent) eventObject).getFaceHealthCheckState();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mHealthCheckStatusTextView.setText(faceHealthCheckState.toString());
            }
        });
    }
    @Override
    public void handleProcessProgressEvent(final int progress) {
        mHealthRenderManager.setHealthCheckProgress(progress);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                setProgressTips(progress);
            }
        });
    }
}); 
private void setProgressTips(int progress) {
    String progressTips = "processing";
    if (progress >= MAX_PROGRESS) {
        progressTips = "finish";
    }
    mProgressTips.setText(progressTips);
    mHealthProgressBar.setProgress(progress);
}


Update data in real-time and display the health check result. 

Java
 
mActivity.runOnUiThread(new Runnable() {
    @Override
    public void run() {
        mHealthParamTable.removeAllViews();
        TableRow heatRateTableRow = initTableRow(ARFace.HealthParameter.PARAMETER_HEART_RATE.toString(),
            healthParams.getOrDefault(ARFace.HealthParameter.PARAMETER_HEART_RATE, 0.0f).toString());
        mHealthParamTable.addView(heatRateTableRow);
        TableRow breathRateTableRow = initTableRow(ARFace.HealthParameter.PARAMETER_BREATH_RATE.toString(),
            healthParams.getOrDefault(ARFace.HealthParameter.PARAMETER_BREATH_RATE, 0.0f).toString());
        mHealthParamTable.addView(breathRateTableRow);
    }
}); 


app Health (Apple)

Opinions expressed by DZone contributors are their own.

Related

  • Allow Users to Track Fitness Status in Your App
  • Turn Your App into a Handy Health Assistant
  • Building a Simple Todo App With Model Context Protocol (MCP)
  • Mastering React App Configuration With Webpack

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!