WD: vital signs sdk changed.

dev_v3.13.6_vital_sign
taha.alam 2 years ago
parent b1bf7032e5
commit 9090adc0d4

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

Loading…
Cancel
Save