camera_for_face.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import '../index.dart';
  4. class CameraForFace extends GetView<FacialRecognitionController> {
  5. const CameraForFace({Key? key}) : super(key: key);
  6. @override
  7. Widget build(BuildContext context) {
  8. return Stack(
  9. children: <Widget>[
  10. // Align(
  11. // alignment: Alignment.center,
  12. // child: OverflowBox(
  13. // maxHeight: 2000,
  14. // maxWidth: 2000,
  15. // child: Container(
  16. // decoration: BoxDecoration(
  17. // border: Border.all(
  18. // color: const Color.fromARGB(80, 0, 0, 0),
  19. // width: 500,
  20. // strokeAlign: BorderSide.strokeAlignOutside,
  21. // ),
  22. // borderRadius: BorderRadius.circular(50),
  23. // ),
  24. // margin: const EdgeInsets.only(bottom: 110),
  25. // child: const SizedBox(
  26. // width: 465,
  27. // height: 430,
  28. // ),
  29. // ),
  30. // ),
  31. // ),
  32. Align(
  33. alignment: Alignment.center,
  34. child: Container(
  35. margin: const EdgeInsets.only(top: 80),
  36. child: const Image(
  37. image: AssetImage('assets/images/face_rec.png'),
  38. width: 800,
  39. ),
  40. ),
  41. ),
  42. Align(
  43. alignment: Alignment.centerRight,
  44. child: Obx(() => Container(
  45. child: controller.state.isRunningFaceRecognition
  46. ? _recognizing()
  47. : _captureButton(),
  48. )),
  49. ),
  50. Align(
  51. alignment: Alignment.bottomCenter,
  52. child: Container(
  53. padding: const EdgeInsets.only(bottom: 40),
  54. child: const Text(
  55. '请将面部保持在识别框内,并确保面部清晰可见,然后按下识别键',
  56. style: TextStyle(color: Colors.white, fontSize: 22),
  57. ),
  58. ),
  59. ),
  60. ],
  61. );
  62. }
  63. /// 拍照按钮
  64. Widget _captureButton() {
  65. return Container(
  66. margin: const EdgeInsets.only(right: 60),
  67. width: 100,
  68. height: 100,
  69. decoration: BoxDecoration(
  70. color: Colors.white,
  71. borderRadius: BorderRadius.circular(50),
  72. ),
  73. child: IconButton(
  74. icon: const Icon(Icons.sensor_occupied, size: 50),
  75. color: Colors.blue,
  76. onPressed: controller.onCaptureFaceButtonPressed,
  77. ),
  78. );
  79. }
  80. /// 识别中状态标识
  81. Widget _recognizing() {
  82. return Container(
  83. margin: const EdgeInsets.only(right: 60),
  84. width: 100,
  85. height: 100,
  86. decoration: BoxDecoration(
  87. color: Colors.white,
  88. borderRadius: BorderRadius.circular(50),
  89. ),
  90. child: const Center(
  91. child: CircularProgressIndicator(
  92. color: Colors.blue,
  93. ),
  94. ),
  95. );
  96. }
  97. }