A ReactNative component to perform rPPG and PPG scanning
npm install react-native-veyetals-native-j8RNVeyetalsNative component is an Android only component to scan user vitals using smartphone camera.
General architecture of the app using RNVeyetalsNative component is as follows:
!RNVeyetalsNative component architecture
Following are the steps to integrate RNVeyetalsNative in your react native application.
RNVeyetalsNative NPM package```
npm i react-native-veyetals-native-j8
Make sure to use version 1.4.2 and above.
---
In project level build.gradle file update core components version as follows:
`gradle`
androidXCore = "1.3.1"
androidXAnnotation = "1.3.0"
androidXBrowser = "1.3.0"
kotlin_version = "1.6.21"
Update Android SDK versions as follows:
`gradle`
minSdkVersion = 23
compileSdkVersion = 30
targetSdkVersion = 30
buildscript repositories object must include following repositories:
`gradle`
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
buildscript dependencies object must include following dependencies:
`gradle`
classpath("com.android.tools.build:gradle:4.1.3")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
allprojects repositories object must include following repositories:
`gradle`
google()
mavenLocal()
jcenter()
Apply following kotlin plugins:
`gradle`
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
Enable databinding in android object:
`gradle`
buildFeatures {
dataBinding true
}
Update Kotlin JVM target to 1.8:
`gradle`
kotlinOptions {
jvmTarget = '1.8'
}
Add dependencies in dependencies object:
`gradle
//lifecycle
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
//Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
//CameraX
implementation "androidx.camera:camera-core:1.0.2"
implementation "androidx.camera:camera-camera2:1.0.2"
implementation "androidx.camera:camera-lifecycle:1.0.2"
implementation "androidx.camera:camera-view:1.0.0-alpha28"
//ML
implementation 'com.google.mlkit:face-detection:16.1.2'
implementation "org.tensorflow:tensorflow-lite:2.2.0"
implementation "org.tensorflow:tensorflow-lite-gpu:2.2.0"
implementation 'org.tensorflow:tensorflow-lite-support:0.0.0-nightly'
//Retrofit
implementation "com.squareup.okhttp3:okhttp:4.7.2"
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
`
component in RN appIntegrating RNVeyetalsNative component in ReactNative application is very straight forward and it requires very little input from the client application. Following code is all that client application requires to integrate RNVeyetalsNative component.
`javascript
import { RNVeyetalsNative } from 'react-native-veyetals-native';
try {
const vitals = await RNVeyetalsNative.start(
if (vitals !== undefined) {
console.log(vitals);
}
} catch (e) {
console.log(e);
}
`
RNVeyetalsNative fully encapsulate the vitals scanning process. RNVeyetalsNative.start() command launches a new Android activity and whole scanning processing takes places within this activity. At the end of the process, client application either get final vitals from the component or it throws an error. Intermediate vitals are not retured to the client application.
Following scanning modes are supported:
face: Get vitals by scanning face.finger: Get vitals by scanning finger.
RNVeyetalsNative also supports lite version whereby only Heart Raten, Heart Rate Variability and stress levels are scanned. Opt for lite version by passing true value for isLiteVersion parameter.
RNVeyetalsNative component may throw following errors:
E_ACTIVITY_DOES_NOT_EXIST: RNVeyetalsNative component couldn't initialize internal activity. RNVeyetalsNative
E_VEYETALS_CANCELLED: Process is cancelled by the user.
E_FAILED_TO_INITIALIZE_VEYETALS: Failed to initialize component.
E_NO_FINAL_RESULTS_FOUND: Component could not generate final vitals for client app.
VeyetalsViewIOS is iOS only ReactNative view to scan user vitals using iPhone Camera.
NPM Package instructions are the same as for Android. Following are the system requirements for integration of VeyetalsViewIOS in React Native iOS application.
iOS Version: 13.0 and above.
Swift Version: 5.0
Camera Usage Permission: Add camera usage string in application's info.plist file
component in iOS app`javascript
import { VeyetalsViewIOS } from 'react-native-veyetals-native';
async function onCompleted(vitals) {
console.log('Veyetals scanning is complete');
//process vitals
//update view
}
async function onCancelled() {
console.log('Veyetals scanning cancelled');
//update view
}
flex: 1,
}}
config={{
userId:
channelId:
mode: [face|finger],
isLightWeight: false,
}}
onComplete={onCompleted}
onCancel={onCancelled}
/>
`
RNVeyetalsComponent internally manages users to keep track of service usage. For this purpose it requires following 3 pieces of information from the client app:
CHANNEL_ID: Uniquely identifies an organisation. SDK clients must request CHANNEL_ID from Veyetals team before integrating the component in their application.
APP_ID: Uniquely identifies an app. A channel may have multiple apps using the RNVeyetalsNative component / VeyetalsViewIOS view. APP_ID is programatically obtained from the client application.
USER_ID: Uniquely identifies an app user for a specific APP_ID and for a specific CHANNEL_ID. Used to track users per app per channel.
These three pieces of information help Veyetals to aggregate the number of users using Veyetals service per app per channel and help generate billing. Before integrating SDK it’s essential for client to contact Veyetals team and activate CHANNEL_ID and APP_ID.
RNVeyetalsNative component doesn’t store users' video or vitals data; neither on the device nor in the cloud. Therefore, it’s responsibility of the client application to protect user data.
```
-1 --> Relaxed
0 --> Normal
1 --> Low Stress
2 --> Medium Stress
3 --> High Stress
4 --> Very High Stress