|
@@ -6,6 +6,9 @@ import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart
|
|
|
import 'package:internal/common/camera.dart';
|
|
|
import 'package:internal/common/transform.dart';
|
|
|
|
|
|
+/// Description: Home Page
|
|
|
+/// Time : 04/12/2023 Wednesday
|
|
|
+/// Author : liuyuqi.gov@msn.cn
|
|
|
class HomeScreen extends StatefulWidget {
|
|
|
const HomeScreen({Key? key}) : super(key: key);
|
|
|
|
|
@@ -13,8 +16,11 @@ class HomeScreen extends StatefulWidget {
|
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
|
}
|
|
|
|
|
|
+/// Description: Home Page State
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
|
+
|
|
|
CameraController? _cameraController;
|
|
|
+ /// 检测器
|
|
|
final ObjectDetector _objectDetector = ObjectDetector(
|
|
|
options: LocalObjectDetectorOptions(
|
|
|
mode: DetectionMode.stream,
|
|
@@ -34,10 +40,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
String message = "";
|
|
|
FlutterTts tts = FlutterTts();
|
|
|
|
|
|
+ /// 初始化状态
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
+
|
|
|
tts.awaitSpeakCompletion(true);
|
|
|
+ /// 检测可用相机
|
|
|
availableCameras().then((cameras) {
|
|
|
CameraDescription cameraDescription = cameras[0];
|
|
|
_cameraController = CameraController(cameraDescription, ResolutionPreset.high, enableAudio: false);
|
|
@@ -47,7 +56,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+ /// 回调函数
|
|
|
Future<void> onImage(InputImage inputImage) async {
|
|
|
if (!_canRender) return;
|
|
|
_canRender = false;
|
|
@@ -89,7 +98,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+ /// 检测指示
|
|
|
Future<void> shouldGUIDELINE(InputImage inputImage) async {
|
|
|
final list = await _objectDetector.processImage(inputImage);
|
|
|
Size? size = _cameraPreviewKey.currentContext?.size;
|
|
@@ -118,6 +127,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
setState(() {});
|
|
|
}
|
|
|
|
|
|
+ /// 执行指示
|
|
|
Future<void> execGUIDELINE(Size size) async {
|
|
|
final Rect rect = _data[0];
|
|
|
if (rect.center.dx < size.width / 2) {
|
|
@@ -143,12 +153,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
final xx = DateTime.now().millisecondsSinceEpoch;
|
|
|
- // print(xx);
|
|
|
- //1676810520479
|
|
|
- //1676810187000
|
|
|
- if (xx >= 1676961078000) {
|
|
|
- Navigator.of(context).pop();
|
|
|
- }
|
|
|
+ // if (xx >= 1676961078000) {
|
|
|
+ // Navigator.of(context).pop();
|
|
|
+ // }
|
|
|
return Scaffold(
|
|
|
appBar: AppBar(
|
|
|
title: const Text("SWIM"),
|