From 103046b5a4b615606f8e3dd63635518e11516644 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 10 Jul 2024 23:31:25 +0200 Subject: [PATCH] test ai --- .../lib/pages/DisplayPictureScreen.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/covas_mobile/lib/pages/DisplayPictureScreen.dart b/covas_mobile/lib/pages/DisplayPictureScreen.dart index 01cc135..ea38a63 100644 --- a/covas_mobile/lib/pages/DisplayPictureScreen.dart +++ b/covas_mobile/lib/pages/DisplayPictureScreen.dart @@ -46,6 +46,26 @@ class DisplayPictureScreen extends StatefulWidget { // A widget that displays the picture taken by the user. class DisplayPictureScreenState extends State { + @override + void initState() { + super.initState(); + + _getEventInfosFromImage(); + } + + Future _getEventInfosFromImage() async { + Gemini.init(apiKey: 'AIzaSyAt1LQIV_hwJQF56sXjb4oxEZEC0wI3PKg'); + final gemini = Gemini.instance; + + final file = File(widget.imagePath); + + gemini + .textAndImage( + text: "What is this picture ?", images: [file.readAsBytesSync()]) + .then((value) => print(value?.content?.parts?.last.text ?? '')) + .catchError((e) => print(e)); + } + @override Widget build(BuildContext context) { return Scaffold(