Как показать модель AR или изображение в модели AR, когда определенный текст распознается с помощью «learning_text_recognition: ^0.0.4» из пакета в flutter

#flutter #flutter-layout #flutter-dependencies #flutter-packages

#трепетать #флаттер-макет #флаттер-зависимости #флаттер-пакеты

Вопрос:

Но наша главная цель-показать модель AR или простое изображение яблока, когда «text_recognition» обнаруживает «яблоко», написанное на странице, как показано на рисунке. Я не могу знать, где вызвать файл кода AR после того, как текст распознается «text_recognition».

введите описание изображения здесь

Файл кода «text_recognition» находится здесь

 import 'package:flutter/material.dart'; import 'package:learning_input_image/learning_input_image.dart'; import 'package:learning_text_recognition/learning_text_recognition.dart'; import 'package:provider/provider.dart';   class MyApp extends StatelessWidget {  @override  Widget build(BuildContext context) {  return MaterialApp(  debugShowCheckedModeBanner: false,  theme: ThemeData(  primarySwatch: Colors.lightBlue,  visualDensity: VisualDensity.adaptivePlatformDensity,  primaryTextTheme: TextTheme(  headline6: TextStyle(color: Colors.white),  ),  ),  home: ChangeNotifierProvider(  create: (_) =gt; TextRecognitionState(),  child: TextRecognitionPage(),  ),  );  } }  class TextRecognitionPage extends StatefulWidget {  @override  _TextRecognitionPageState createState() =gt; _TextRecognitionPageState(); }  class _TextRecognitionPageState extends Statelt;TextRecognitionPagegt; {  TextRecognition? _textRecognition = TextRecognition();   /* TextRecognition? _textRecognition = TextRecognition(  options: TextRecognitionOptions.Japanese  ); */   @override  void dispose() {  _textRecognition?.dispose();  super.dispose();  }   Futurelt;voidgt; _startRecognition(InputImage image) async {  TextRecognitionState state = Provider.of(context, listen: false);   if (state.isNotProcessing) {  state.startProcessing();  state.image = image;  state.data = await _textRecognition?.process(image);  state.stopProcessing();  }  }   @override  Widget build(BuildContext context) {  return InputCameraView(  mode: InputCameraMode.gallery,  // resolutionPreset: ResolutionPreset.high,  title: 'Text Recognition',  onImage: _startRecognition,  overlay: Consumerlt;TextRecognitionStategt;(  builder: (_, state, __) {  if (state.isNotEmpty) {  return Center(  child: Container(  padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16),  decoration: BoxDecoration(  color: Colors.white.withOpacity(0.8),  borderRadius: BorderRadius.all(Radius.circular(4.0)),  ),  child: Text(  state.text,  style: TextStyle(  fontWeight: FontWeight.w500,  ),  ),  ),  );  }   return Container();  },  ),  );  } }  class TextRecognitionState extends ChangeNotifier {  InputImage? _image;  RecognizedText? _data;  bool _isProcessing = false;   InputImage? get image =gt; _image;  RecognizedText? get data =gt; _data;  String get text =gt; _data!.text;  bool get isNotProcessing =gt; !_isProcessing;  bool get isNotEmpty =gt; _data != null amp;amp; text.isNotEmpty;   void startProcessing() {  _isProcessing = true;  notifyListeners();  }   void stopProcessing() {  _isProcessing = false;  notifyListeners();  }   set image(InputImage? image) {  _image = image;  notifyListeners();  }   set data(RecognizedText? data) {  _data = data;  notifyListeners();  } }  

Ar model code is here

 import 'package:arcore_flutter_plugin/arcore_flutter_plugin.dart';  import 'package:flutter/material.dart';  import 'package:flutter/services.dart';  import 'package:vector_math/vector_math_64.dart' as vector;   class HelloWorld extends StatefulWidget {  @override  _HelloWorldState createState() =gt; _HelloWorldState(); }  class _HelloWorldState extends Statelt;HelloWorldgt; {  ArCoreController arCoreController;   @override  Widget build(BuildContext context) {  return MaterialApp(  home: Scaffold(  appBar: AppBar(  title: const Text('Hello World'),  ),  body: ArCoreView(  onArCoreViewCreated: _onArCoreViewCreated,  ),  ),  );  }   void _onArCoreViewCreated(ArCoreController controller) {  arCoreController = controller;   _addSphere(arCoreController);  _addCylindre(arCoreController);  _addCube(arCoreController);  }   Future _addSphere(ArCoreController controller) async {  final ByteData textureBytes = await rootBundle.load('assets/earth.jpg');   final material = ArCoreMaterial(  color: Color.fromARGB(120, 66, 134, 244),  textureBytes: textureBytes.buffer.asUint8List());  final sphere = ArCoreSphere(  materials: [material],  radius: 0.1,  );  final node = ArCoreNode(  shape: sphere,  position: vector.Vector3(0, 0, -1.5),  );  controller.addArCoreNode(node);  }   void _addCylindre(ArCoreController controller) {  final material = ArCoreMaterial(  color: Colors.red,  reflectance: 1.0,  );  final cylindre = ArCoreCylinder(  materials: [material],  radius: 0.5,  height: 0.3,  );  final node = ArCoreNode(  shape: cylindre,  position: vector.Vector3(0.0, -0.5, -2.0),  );  controller.addArCoreNode(node);  }   void _addCube(ArCoreController controller) {  final material = ArCoreMaterial(  color: Color.fromARGB(120, 66, 134, 244),  metallic: 1.0,  );  final cube = ArCoreCube(  materials: [material],  size: vector.Vector3(0.5, 0.5, 0.5),  );  final node = ArCoreNode(  shape: cube,  position: vector.Vector3(-0.5, 0.5, -3.5),  );  controller.addArCoreNode(node);  }   @override  void dispose() {  arCoreController.dispose();  super.dispose();  } }