The plan of the year lies in spring, and we have ushered in a good time for fitness in the recovery of all things. As a programmer, you often sit or sit at your desk for a long time, which brings about sub-health conditions such as lumbar muscle strain and cervical pain. Have you started to formulate sports flags for this? At the same time, do you want to check your own health indicators at all times?
Why not experience the body and face tracking capabilities provided by the HMS Core AR Engine service (currently only supports face tracking)! By integrating the AR core algorithm, it can monitor your heart rate, breathing rate, facial health status, heart rate waveform signal and other health information in real time during your exercise. In addition to self-health, developers can also integrate it into applications in different industries, such as real-time viewing of people's movement status in gyms; real-time physical examination of patients in hospitals; real-time monitoring of elderly and disabled people in the nursing industry. Item indicators, etc., provide a new visual experience and interaction method for the application.
1. Advantages and model requirements of face tracking capability
- Real-time calculation of face health information and key human health information, including heart rate, respiration rate, facial health status, heart rate waveform signal, etc.
- Let the terminal device have the ability to understand people. SLAM, 3D reconstruction and other technologies are used to realize the 3D perception of the face in the real world, and finally the virtual and real fusion effect of AR is presented on the mobile phone application side by means of image rendering.
- For the specific supported situation of the model, please refer to the software and hardware dependency table of the pipe network description.
2. Demo application introduction
In order to let developers better understand the human body and face tracking capabilities provided by the HMS Core AR Engine service, here is a simple integration case to teach you how to run the demo in a fast and efficient way and with simple code.
- ENABLE_HEALTH_DEVICE Enable health detection, 1 << 6.
- HealthParameter health detection parameters (heart rate; breathing rate; face attributes: age, specific gravity; heart rate waveform signal, etc.)
- FaceDetectMode face detection mode (including health check heart rate; health check breathing rate; health real-time detection; enable heart rate, breathing rate and real-time monitoring mode at the same time)
Page renderings:
The following is an introduction to how to run this Demo according to the source code, so as to understand the implementation details.
3. Description of key steps
1. Add Huawei maven warehouse to project-level gradle.
buildscript {
repositories {
maven { url 'http://developer.huawei.com/repo/'}
}
dependencies {
...
// 增加agcp配置。
classpath 'com.huawei.agconnect:agcp:1.4.2.300'
}
}allprojects {
repositories {
maven { url 'http://developer.huawei.com/repo/'}
}
}
2. Add SDK dependencies to the application-level build.gradle.
implementation 'com.huawei.hms:arenginesdk:3.7.0.3'
3. Declare system permissions in the AndroidManifest.xml file.
:<uses-permission android:name="android.permission.CAMERA" />
4. Check whether the AR Engine is installed on the current device. If it is installed, it will run normally. If it is not installed, the App should actively jump to the App Market and request to install the AR Engine.
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);
Fourth, the key code description
1. Call the ARFaceTrackingConfig interface to create a face tracking ARSession scene, set the face detection mode, configure motion tracking AR scene parameters, and start motion tracking.
mArSession = new ARSession(this);
mArFaceTrackingConfig = new ARFaceTrackingConfig(mArSession);
mArFaceTrackingConfig.setEnableItem(ARConfigBase.ENABLE_HEALTH_DEVICE);
mArFaceTrackingConfig
.setFaceDetectMode(ARConfigBase.FaceDetectMode.HEALTH_ENABLE_DEFAULT.getEnumValue());
2. Call the FaceHealthServiceListener health detection event monitoring interface, and add the monitoring application to transmit information such as health detection status and progress. Call back the health check progress in handleProcessProgressEvent().
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 the page data in real time to display the current detection results:
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);
}
});
For more HMS Core AR Engine service details
Learn more >>
Visit Huawei Developer Alliance official website
Get the development guidance document
Huawei Mobile Services open source warehouse address: GitHub , Gitee
us and know the latest technical information of HMS Core for the first time~
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。