WD: vital signs sdk changed.

dev_v3.13.6_vital_sign
taha.alam 1 year ago
parent b1bf7032e5
commit 9090adc0d4

@ -1,6 +1,6 @@
include ':app'
include ':vital-sign-engine'
project(':vital-sign-engine').projectDir = new File('/Users/mohamedmekawy/Documents/Work/DiplomaticQuarter_3.16/packages/vital_sign_camera/android/libs')
project(':vital-sign-engine').projectDir = new File('../packages/vital_sign_camera/android/libs')
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

@ -1,4 +1,3 @@
import 'package:diplomaticquarterapp/vital_signs/result_screen.dart';
import 'package:flutter/material.dart';
import 'package:vital_sign_camera/vital_sign_camera.dart';
// import 'package:wakelock/wakelock.dart';
@ -10,22 +9,19 @@ import 'components/scan_status.dart';
import 'components/start_button.dart';
import 'components/back_button.dart';
import 'components/button.dart';
// import 'result_screen.dart';
// import 'main.dart';
import 'result_screen.dart';
final UserInfo userInfo = UserInfo(
age: 30,
gender: Gender.male,
weight: 60,
// kg, Optional
height: 170,
// cm, Optional
waistCircumference: 71,
// cm Optional
weight: 75, // kg, Optional
height: 164, // cm, Optional
waistCircumference: 83, // cm Optional
userId: 'dbd13e86-47f4-4a43-85f6-cf62fa750117');
final VitalSignCameraConfig config = VitalSignCameraConfig(apiKey: 'nIsZO45woSXSfIxsL1t79MWeIpsnGQr6B941MSF2', serverId: ServerId.awsEnterpriseProd);
final VitalSignCameraConfig config = VitalSignCameraConfig(
apiKey: 'nIsZO45woSXSfIxsL1t79MWeIpsnGQr6B941MSF2',
serverId: ServerId.awsEnterpriseProd);
class VitalSigns extends StatefulWidget {
const VitalSigns({super.key});
@ -52,8 +48,10 @@ class _VitalSignsState extends State<VitalSigns> with RouteAware {
return queryCameraDevice(CameraPosition.front);
}
bool startedScanning = false; // set true when start button is pressed, set false when health result is tapped or error occurs
bool isAllConditionsMet = false; // check for the 6 scan conditions before enabling the start button
bool startedScanning =
false; // set true when start button is pressed, set false when health result is tapped or error occurs
bool isAllConditionsMet =
false; // check for the 6 scan conditions before enabling the start button
ScanConditions? _conditions;
GetHealthStage? _scanningStage;
@ -64,7 +62,7 @@ class _VitalSignsState extends State<VitalSigns> with RouteAware {
dynamic _error;
int? _errorCode;
bool isCameraActive = true;
bool _showingResultPage = false;
bool _showedHealthResult = false;
@override
void didChangeDependencies() {
@ -81,7 +79,6 @@ class _VitalSignsState extends State<VitalSigns> with RouteAware {
@override
void didPushNext() {
setState(() {
_showingResultPage = true;
isCameraActive = false;
});
}
@ -92,7 +89,6 @@ class _VitalSignsState extends State<VitalSigns> with RouteAware {
isCameraActive = true;
startedScanning = false;
_healthResult = null;
_showingResultPage = false;
});
}
@ -103,7 +99,13 @@ class _VitalSignsState extends State<VitalSigns> with RouteAware {
return Scaffold(
body: Stack(
children: [
VitalSignCamera(onCreated: _onVitalSignCameraCreated, isActive: isCameraActive, userInfo: userInfo, config: config, device: cameraDevice, onVideoFrameProcessed: _onVideoFrameProcessed),
VitalSignCamera(
onCreated: _onVitalSignCameraCreated,
isActive: isCameraActive,
userInfo: userInfo,
config: config,
device: cameraDevice,
onVideoFrameProcessed: _onVideoFrameProcessed),
// A back button to navigate back to previous screen
if (_scanningStage == GetHealthStage.idle && !startedScanning)
BackHomeButton(
@ -125,32 +127,46 @@ class _VitalSignsState extends State<VitalSigns> with RouteAware {
deviceSize: deviceSize,
title: "Toggle isCameraActive",
alignment: Alignment.topRight,
margin: EdgeInsets.fromLTRB(0, deviceSize.height * 0.05, deviceSize.width * 0.05, 0)),
margin: EdgeInsets.fromLTRB(
0, deviceSize.height * 0.05, deviceSize.width * 0.05, 0)),
if (!isCameraActive)
const Center(
child: Text(
"Camera is not active.",
textAlign: TextAlign.center,
))
"Camera is not active.",
textAlign: TextAlign.center,
))
else
Stack(children: [
if (_scanningStage == GetHealthStage.idle && isCameraActive) // show start button only when it is not scanning
if (_scanningStage == GetHealthStage.idle &&
isCameraActive) // show start button only when it is not scanning
StartButton(
onPressed: () {
setState(() {
_vitalSignCameraController.startScanning();
startedScanning = true;
_healthResult = null;
_showedHealthResult = false;
});
},
disabled: !isAllConditionsMet,
),
if (_conditions != null && _scanningStage == GetHealthStage.idle && !startedScanning) // show scan conditions checking only when it is not scanning or showing health result
ScanConditionChecklist(deviceSize: deviceSize, conditions: _conditions!),
if (_scanningStage != GetHealthStage.idle) // show remaining time count down during scan
ScanStatus(stage: _scanningStage, remainingTime: _remainingTime),
if (!startedScanning || _healthResult == null) // show bounding box before and during scan, but not when health result is shown
BoundingBoxWidget(deviceSize: deviceSize, facebox: _normalizedFaceBox, videoFrameInfo: _videoFrameInfo),
if (_conditions != null &&
_scanningStage == GetHealthStage.idle &&
!startedScanning) // show scan conditions checking only when it is not scanning or showing health result
ScanConditionChecklist(
deviceSize: deviceSize, conditions: _conditions!),
if (_scanningStage !=
GetHealthStage
.idle) // show remaining time count down during scan
ScanStatus(
stage: _scanningStage, remainingTime: _remainingTime),
if (!startedScanning ||
_healthResult ==
null) // show bounding box before and during scan, but not when health result is shown
BoundingBoxWidget(
deviceSize: deviceSize,
facebox: _normalizedFaceBox,
videoFrameInfo: _videoFrameInfo),
if (_error != null) Error(error: _error, errorCode: _errorCode),
])
],
@ -159,11 +175,10 @@ class _VitalSignsState extends State<VitalSigns> with RouteAware {
}
void _onVideoFrameProcessed(VideoFrameProcessedEvent event) {
if (_showingResultPage) {
return;
}
if (_healthResult == null && event.healthResult?.health != null && event.healthResult?.stage == GetHealthStage.analyzingData) {
if (!_showedHealthResult &&
_healthResult == null &&
event.healthResult?.health != null) {
_showedHealthResult = true;
Navigator.push(
context,
MaterialPageRoute(

Loading…
Cancel
Save