|
@@ -49,14 +49,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
/// 检测可用相机
|
|
|
availableCameras().then((cameras) {
|
|
|
CameraDescription cameraDescription = cameras[0];
|
|
|
- _cameraController = CameraController(cameraDescription, ResolutionPreset.high, enableAudio: false);
|
|
|
+ _cameraController = CameraController(cameraDescription, ResolutionPreset.high, enableAudio: false); // ResolutionPreset.high 质量较高的预设,不录音
|
|
|
_cameraController!.initialize().then((_) {
|
|
|
_cameraController!.startImageStream((image) => processCameraImage(cameraDescription, image, onImage));
|
|
|
setState(() {});
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
- /// 回调函数
|
|
|
+
|
|
|
+ /// 回调函数,处理camera拍摄的图片
|
|
|
Future<void> onImage(InputImage inputImage) async {
|
|
|
if (!_canRender) return;
|
|
|
_canRender = false;
|
|
@@ -65,9 +66,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
if (!xx) await shouldGUIDELINE(inputImage);
|
|
|
_canRender = true;
|
|
|
}
|
|
|
-
|
|
|
+ /// 是否需要旋转图片
|
|
|
+ /// [inputImage] 图片
|
|
|
Future<bool> shouldTURNAROUND(InputImage inputImage) async {
|
|
|
- final list = await _textDetector.processImage(inputImage);
|
|
|
+ final list = await _textDetector.processImage(inputImage); // 识别文字
|
|
|
Size? size = _cameraPreviewKey.currentContext?.size;
|
|
|
if (size == null) {
|
|
|
return false;
|
|
@@ -89,6 +91,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
message = "TURN AROUND";
|
|
|
if (_canSpace) {
|
|
|
_canSpace = false;
|
|
|
+ // 语音播放:打开录音
|
|
|
tts.speak("TURN AROUND").then((_) => _canSpace = true);
|
|
|
}
|
|
|
_data.addAll(data);
|
|
@@ -98,9 +101,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- /// 检测指示
|
|
|
+ /// 是否需要引导
|
|
|
Future<void> shouldGUIDELINE(InputImage inputImage) async {
|
|
|
- final list = await _objectDetector.processImage(inputImage);
|
|
|
+ final list = await _objectDetector.processImage(inputImage); // 识别物体
|
|
|
Size? size = _cameraPreviewKey.currentContext?.size;
|
|
|
if (size == null) {
|
|
|
return;
|