Pārlūkot izejas kodu

优化生物识别流程

gavin.chen 1 gadu atpakaļ
vecāks
revīzija
9a57bf9be0

BIN
assets/images/face_rec.png


+ 8 - 17
lib/pages/facial_recognition/controller.dart

@@ -8,6 +8,7 @@ import 'package:get/get.dart';
 import 'package:image_gallery_saver/image_gallery_saver.dart';
 import 'package:vitalapp/architecture/utils/prompt_box.dart';
 import 'package:vitalapp/managers/interfaces/cache.dart';
+import 'package:fis_common/logger/logger.dart';
 import 'dart:ui' as ui;
 import 'index.dart';
 
@@ -25,13 +26,6 @@ class FacialRecognitionController extends GetxController
   double _maxAvailableExposureOffset = 0.0;
   double _minAvailableZoom = 1.0;
   double _maxAvailableZoom = 1.0;
-
-  // CameraController? controller;
-  XFile? imageFile;
-  XFile? videoFile;
-  // VideoPlayerController? videoController;
-  VoidCallback? videoPlayerListener;
-  bool enableAudio = true;
   double _currentScale = 1.0;
   double _baseScale = 1.0;
 
@@ -60,7 +54,7 @@ class FacialRecognitionController extends GetxController
     // await kCameraController!.setZoomLevel(_currentScale);
   }
 
-  /// 修改对焦点 TODO
+  /// 修改对焦点 [暂不执行]
   void onViewFinderTap(TapDownDetails details, BoxConstraints constraints) {
     if (kCameraController == null) {
       return;
@@ -83,9 +77,9 @@ class FacialRecognitionController extends GetxController
       if (_cameras.isNotEmpty) {
         // state.isCameraReady = true;
       }
-      print("cameras: ${_cameras.length}");
+      // print("cameras: ${_cameras.length}");
     } on CameraException catch (e) {
-      print("cameras: ${e.code} ${e.description}");
+      logger.e("cameras: ${e.code} ${e.description}");
     }
   }
 
@@ -233,9 +227,10 @@ class FacialRecognitionController extends GetxController
   void debugShowCache() async {
     final cacheManager = Get.find<ICacheManager>();
     double cacheSize = await cacheManager.getCacheSize();
-    print('cacheSize = $cacheSize : ${formatSize(cacheSize)}');
     double imageCacheSize = await cacheManager.getImageCacheSize();
-    print('imageCacheSize = $imageCacheSize : ${formatSize(imageCacheSize)}');
+    debugPrint('cacheSize = $cacheSize : ${formatSize(cacheSize)}');
+    debugPrint(
+        'imageCacheSize = $imageCacheSize : ${formatSize(imageCacheSize)}');
   }
 
   static String formatSize(double value) {
@@ -255,8 +250,6 @@ class FacialRecognitionController extends GetxController
 
     // 将图像保存到相册
     await ImageGallerySaver.saveImage(bytes, quality: 100);
-
-    print('图像已保存到相册!');
   }
 
   /// 处理图像裁切
@@ -306,9 +299,7 @@ class FacialRecognitionController extends GetxController
     takePicture().then((XFile? file) async {
       // imageFile = file;
       if (file != null) {
-        print('Picture saved to ${file.path}');
-        String savePath = await clipLocalImage(file, 1.8);
-        print('clipPicture saved to $savePath');
+        await clipLocalImage(file, 1.8);
 
         /// TODO 上传给server,获取返回值信息
         if (true) {

+ 4 - 2
lib/pages/facial_recognition/view.dart

@@ -21,8 +21,10 @@ class FacialRecognitionPage extends GetView<FacialRecognitionController> {
               () => controller.state.isCameraReady
                   // ? const CameraForIdCard()
                   ? _buildCameraArea()
-                  : const CircularProgressIndicator(
-                      valueColor: AlwaysStoppedAnimation<Color>(Colors.orange),
+                  : const Center(
+                      child: CircularProgressIndicator(
+                        valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
+                      ),
                     ),
             ),
           ),

+ 16 - 6
lib/pages/facial_recognition/widgets/camera_for_face.dart

@@ -17,20 +17,30 @@ class CameraForFace extends GetView<FacialRecognitionController> {
             child: Container(
               decoration: BoxDecoration(
                 border: Border.all(
-                  color: const Color.fromARGB(90, 0, 0, 0),
-                  width: 400,
+                  color: const Color.fromARGB(80, 0, 0, 0),
+                  width: 500,
                   strokeAlign: BorderSide.strokeAlignOutside,
                 ),
-                borderRadius: BorderRadius.circular(20),
+                borderRadius: BorderRadius.circular(50),
               ),
-              margin: const EdgeInsets.only(bottom: 60),
+              margin: const EdgeInsets.only(bottom: 110),
               child: const SizedBox(
-                width: 500,
-                height: 600,
+                width: 465,
+                height: 430,
               ),
             ),
           ),
         ),
+        Align(
+          alignment: Alignment.center,
+          child: Container(
+            margin: const EdgeInsets.only(top: 80),
+            child: const Image(
+              image: AssetImage('assets/images/face_rec.png'),
+              width: 800,
+            ),
+          ),
+        ),
         Align(
           alignment: Alignment.centerRight,
           child: Container(