|
@@ -8,9 +8,12 @@ import 'package:flutter/services.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:google_mlkit_face_detection/google_mlkit_face_detection.dart';
|
|
|
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
|
|
+import 'package:vitalapp/architecture/storage/storage.dart';
|
|
|
import 'package:vitalapp/architecture/utils/prompt_box.dart';
|
|
|
import 'package:vitalapp/managers/interfaces/cache.dart';
|
|
|
import 'package:fis_common/logger/logger.dart';
|
|
|
+import 'package:vitalapp/rpc.dart';
|
|
|
+import 'package:vitalapp/store/store.dart';
|
|
|
import 'dart:ui' as ui;
|
|
|
import 'index.dart';
|
|
|
|
|
@@ -337,18 +340,29 @@ class IdCardScanController extends GetxController with WidgetsBindingObserver {
|
|
|
takePicture().then((XFile? file) async {
|
|
|
// imageFile = file;
|
|
|
if (file != null) {
|
|
|
- await clipLocalImage(file, 1.8);
|
|
|
+ // await clipLocalImage(file, 1.8);
|
|
|
+ final url = await rpc.storage.upload(
|
|
|
+ file,
|
|
|
+ fileType: 'png',
|
|
|
+ );
|
|
|
+ PatientBaseDTO result = await rpc.patient.getPatientBaseByImageAsync(
|
|
|
+ GetPatientBaseByImageRequest(
|
|
|
+ token: Store.user.token,
|
|
|
+ image: url,
|
|
|
+ ),
|
|
|
+ );
|
|
|
|
|
|
/// TODO 上传给server,获取返回值信息
|
|
|
- if (true) {
|
|
|
+ if (result.isSuccess) {
|
|
|
PromptBox.toast('身份证识别成功');
|
|
|
idCardInfo.localCardImagePath = file.path;
|
|
|
- idCardInfo.idCardName = '金阳';
|
|
|
- idCardInfo.idCardGender = '女';
|
|
|
- idCardInfo.idCardNation = '汉';
|
|
|
- idCardInfo.idCardBirthDate = '1980年10月27日';
|
|
|
- idCardInfo.idCardAddress = '北京市西城区复兴门外大街999号院11号楼3单元502室';
|
|
|
- idCardInfo.idCardNumber = '110101198010270000';
|
|
|
+ idCardInfo.idCardName = result.patientName ?? "";
|
|
|
+ idCardInfo.idCardGender =
|
|
|
+ result.patientGender == GenderEnum.Male ? "男" : "女";
|
|
|
+ idCardInfo.idCardNation = result.nationality ?? "";
|
|
|
+ idCardInfo.idCardBirthDate = result.birthday.toString();
|
|
|
+ idCardInfo.idCardAddress = result.patientAddress ?? "";
|
|
|
+ idCardInfo.idCardNumber = result.cardNo ?? "";
|
|
|
state.isShowIdCardInfoSwitch = true;
|
|
|
state.isIdCardInfoShow = true;
|
|
|
state.isInIdCardScan = true;
|
|
@@ -362,7 +376,74 @@ class IdCardScanController extends GetxController with WidgetsBindingObserver {
|
|
|
|
|
|
/// 发生开始人脸识别事件
|
|
|
void onCaptureFaceButtonPressed() {
|
|
|
- runDetectionTimer();
|
|
|
+ // runDetectionTimer();
|
|
|
+ rpcTest2();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 人脸录入测试
|
|
|
+ void rpcTest2() async {
|
|
|
+ if (kCameraController == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ final XFile? file = await takePicture();
|
|
|
+ if (file != null) {
|
|
|
+ faceDetector = FaceDetector(options: FaceDetectorOptions());
|
|
|
+ // faceDetector =
|
|
|
+ // FaceDetector(options: FaceDetectorOptions(enableContours: true));
|
|
|
+ int faceNum = 1; // max 分辨率下检测用时大约 100ms
|
|
|
+ // int faceNum =
|
|
|
+ // await doDetection(faceDetector, file.path); // max 分辨率下检测用时大约 100ms
|
|
|
+
|
|
|
+ if (faceNum == 0) {
|
|
|
+ PromptBox.toast('请将面部保持在识别框内');
|
|
|
+ return;
|
|
|
+ } else if (faceNum > 1) {
|
|
|
+ PromptBox.toast('请保持只有一张面部在识别范围内');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// TODO 上传图像到云然后传给后端
|
|
|
+ final url = await rpc.storage.upload(
|
|
|
+ file,
|
|
|
+ fileType: 'png',
|
|
|
+ );
|
|
|
+ print('⭐⭐⭐⭐⭐⭐⭐⭐ url: $url');
|
|
|
+ try {
|
|
|
+ SavePersonDTO result =
|
|
|
+ await rpc.patient.savePatientBaseByFaceImageAsync(
|
|
|
+ SavePatientBaseByFaceImageRequest(
|
|
|
+ cardNo: idCardInfo.idCardNumber,
|
|
|
+ token: Store.user.token,
|
|
|
+ image: url,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ print(result);
|
|
|
+ if (result.success) {
|
|
|
+ PromptBox.toast('人脸数据存入成功');
|
|
|
+ } else {
|
|
|
+ PromptBox.toast('人脸数据存入失败: ${result.errMessage}');
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ logger.e("savePatientBaseByFaceImageAsync failed: $e", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ // if (timer.tick == 1 || kFrameImageSize == Size.zero) {
|
|
|
+ // Size imageSize = await getImageSize(file);
|
|
|
+ // kFrameImageSize = imageSize;
|
|
|
+ // }
|
|
|
+ // int kTime = DateTime.now().millisecondsSinceEpoch;
|
|
|
+ // print('⭐⭐⭐⭐⭐⭐⭐⭐ capture time: ${kTime - lastCaptureTime} ms');
|
|
|
+ // lastCaptureTime = kTime;
|
|
|
+
|
|
|
+ // /// 记录用时 ms
|
|
|
+
|
|
|
+ // int endTime = DateTime.now().millisecondsSinceEpoch;
|
|
|
+ // print('⭐⭐⭐⭐⭐⭐⭐⭐ detection time: ${endTime - lastCaptureTime} ms');
|
|
|
+ // update(['face_bounding_box']);
|
|
|
+ // if (timer.tick >= 10) {
|
|
|
+ // finishFaceDetection(); // TODO 接入真实的判断条件
|
|
|
+ // }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// 发生结束录制视频事件
|