summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-10-13 17:35:29 +0300
committerxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-10-13 17:35:29 +0300
commit14e3807c7c238a2ea1879f79da820be303cfb3ed (patch)
tree03d64931f14bc9be2f3c218546b775c3ff8a7e32
parent07150b61d3593fc9ad764a7884e50a5190178e1b (diff)
Fixed Icon Breakage
Changes to be committed: deleted: android/app/src/main/res/AndroidManifest.xml new file: android/app/src/main/res/drawable-hdpi/ic_launcher_background.png new file: android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png new file: android/app/src/main/res/drawable-mdpi/ic_launcher_background.png new file: android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png new file: android/app/src/main/res/drawable-xhdpi/ic_launcher_background.png new file: android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png new file: android/app/src/main/res/drawable-xxhdpi/ic_launcher_background.png new file: android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png new file: android/app/src/main/res/drawable-xxxhdpi/ic_launcher_background.png new file: android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png new file: android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml modified: android/app/src/main/res/mipmap-hdpi/ic_launcher.png modified: android/app/src/main/res/mipmap-mdpi/ic_launcher.png modified: android/app/src/main/res/mipmap-xhdpi/ic_launcher.png modified: android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png modified: android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file: android/app/src/main/res/values/colors.xml modified: lib/main.dart
-rw-r--r--android/app/src/main/res/AndroidManifest.xml38
-rw-r--r--android/app/src/main/res/drawable-hdpi/ic_launcher_background.pngbin0 -> 1122 bytes
-rw-r--r--android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.pngbin0 -> 1122 bytes
-rw-r--r--android/app/src/main/res/drawable-mdpi/ic_launcher_background.pngbin0 -> 673 bytes
-rw-r--r--android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.pngbin0 -> 673 bytes
-rw-r--r--android/app/src/main/res/drawable-xhdpi/ic_launcher_background.pngbin0 -> 1636 bytes
-rw-r--r--android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.pngbin0 -> 1636 bytes
-rw-r--r--android/app/src/main/res/drawable-xxhdpi/ic_launcher_background.pngbin0 -> 2915 bytes
-rw-r--r--android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.pngbin0 -> 2915 bytes
-rw-r--r--android/app/src/main/res/drawable-xxxhdpi/ic_launcher_background.pngbin0 -> 4362 bytes
-rw-r--r--android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.pngbin0 -> 4362 bytes
-rw-r--r--android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml5
-rw-r--r--android/app/src/main/res/mipmap-hdpi/ic_launcher.pngbin544 -> 445 bytes
-rw-r--r--android/app/src/main/res/mipmap-mdpi/ic_launcher.pngbin442 -> 322 bytes
-rw-r--r--android/app/src/main/res/mipmap-xhdpi/ic_launcher.pngbin721 -> 604 bytes
-rw-r--r--android/app/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin1031 -> 973 bytes
-rw-r--r--android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.pngbin1443 -> 1416 bytes
-rw-r--r--android/app/src/main/res/values/colors.xml4
-rw-r--r--lib/main.dart346
19 files changed, 10 insertions, 383 deletions
diff --git a/android/app/src/main/res/AndroidManifest.xml b/android/app/src/main/res/AndroidManifest.xml
deleted file mode 100644
index dd90eee..0000000
--- a/android/app/src/main/res/AndroidManifest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android">
-
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-feature android:name="android.hardware.camera" />
- <uses-feature android:name="android.hardware.camera.autofocus" />
-
- <application
- android:label="MegaView"
- android:name="${applicationName}"
- android:icon="@mipmap/ic_launcher">
- <activity
- android:name=".MainActivity"
- android:exported="true"
- android:launchMode="singleTop"
- android:theme="@style/LaunchTheme"
- android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
- android:hardwareAccelerated="true"
- android:windowSoftInputMode="adjustResize">
- <!-- Specifies an Android theme to apply to this Activity as soon as
- the Android process has started. This theme is visible to the user
- while the Flutter UI initializes. After that, this theme continues
- to determine the Window background behind the Flutter UI. -->
- <meta-data
- android:name="io.flutter.embedding.android.NormalTheme"
- android:resource="@style/NormalTheme"
- />
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- </activity>
- <!-- Don't delete the meta-data below.
- This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
- <meta-data
- android:name="flutterEmbedding"
- android:value="2" />
- </application>
-</manifest>
diff --git a/android/app/src/main/res/drawable-hdpi/ic_launcher_background.png b/android/app/src/main/res/drawable-hdpi/ic_launcher_background.png
new file mode 100644
index 0000000..e127458
--- /dev/null
+++ b/android/app/src/main/res/drawable-hdpi/ic_launcher_background.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..e127458
--- /dev/null
+++ b/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-mdpi/ic_launcher_background.png b/android/app/src/main/res/drawable-mdpi/ic_launcher_background.png
new file mode 100644
index 0000000..4f53b51
--- /dev/null
+++ b/android/app/src/main/res/drawable-mdpi/ic_launcher_background.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..4f53b51
--- /dev/null
+++ b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-xhdpi/ic_launcher_background.png b/android/app/src/main/res/drawable-xhdpi/ic_launcher_background.png
new file mode 100644
index 0000000..335a110
--- /dev/null
+++ b/android/app/src/main/res/drawable-xhdpi/ic_launcher_background.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..335a110
--- /dev/null
+++ b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_launcher_background.png b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_background.png
new file mode 100644
index 0000000..a255ceb
--- /dev/null
+++ b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_background.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..a255ceb
--- /dev/null
+++ b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_background.png b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_background.png
new file mode 100644
index 0000000..eaf610c
--- /dev/null
+++ b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_background.png
Binary files differ
diff --git a/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..eaf610c
--- /dev/null
+++ b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png
Binary files differ
diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..5f349f7
--- /dev/null
+++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@color/ic_launcher_background"/>
+ <foreground android:drawable="@drawable/ic_launcher_foreground"/>
+</adaptive-icon>
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
index db77bb4..60dc7d8 100644
--- a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
+++ b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
index 17987b7..519150a 100644
--- a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
+++ b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index 09d4391..5077421 100644
--- a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
+++ b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index d5f1c8d..8f62be2 100644
--- a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
+++ b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index 4d6372e..d11eb7f 100644
--- a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
+++ b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..beab31f
--- /dev/null
+++ b/android/app/src/main/res/values/colors.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="ic_launcher_background">#000000</color>
+</resources> \ No newline at end of file
diff --git a/lib/main.dart b/lib/main.dart
index 173a152..dfa3a69 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -6,7 +6,7 @@ import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart
// import 'package:flutter_speed_dial/flutter_speed_dial.dart';
import 'package:flutter_tts/flutter_tts.dart';
import 'package:flutter_vision/flutter_vision.dart';
-import 'package:image_picker/image_picker.dart';
+// import 'package:image_picker/image_picker.dart';
// import 'package:yolo/result_screen.dart';
import 'package:flutter/material.dart';
@@ -436,348 +436,4 @@ class _YoloVideoState extends State<YoloVideo> {
);
}).toList();
}
-}
-
-// YOLO V5 OBJECT DETECTION
-
-class YoloImageV5 extends StatefulWidget {
- final FlutterVision vision;
- const YoloImageV5({Key? key, required this.vision}) : super(key: key);
-
- @override
- State<YoloImageV5> createState() => _YoloImageV5State();
-}
-
-class _YoloImageV5State extends State<YoloImageV5> {
- late List<Map<String, dynamic>> yoloResults;
- File? imageFile;
- int imageHeight = 1;
- int imageWidth = 1;
- bool isLoaded = false;
-
- @override
- void initState() {
- super.initState();
- loadYoloModel().then((value) {
- setState(() {
- yoloResults = [];
- isLoaded = true;
- });
- });
- }
-
- @override
- void dispose() async {
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- final Size size = MediaQuery.of(context).size;
- if (!isLoaded) {
- return const Scaffold(
- body: Center(
- child: Text("Model not loaded, waiting for it"),
- ),
- );
- }
- return Stack(
- fit: StackFit.expand,
- children: [
- imageFile != null ? Image.file(imageFile!) : const SizedBox(),
- Align(
- alignment: Alignment.bottomCenter,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TextButton(
- onPressed: pickImage,
- child: const Text("Pick image"),
- ),
- ElevatedButton(
- onPressed: yoloOnImage,
- child: const Text("Detect"),
- )
- ],
- ),
- ),
- ...displayBoxesAroundRecognizedObjects(size),
- ],
- );
- }
-
- Future<void> loadYoloModel() async {
- await widget.vision.loadYoloModel(
- labels: 'assets/labels.txt',
- modelPath: 'assets/yolov5n.tflite',
- modelVersion: "yolov5",
- quantization: false,
- numThreads: 2,
- useGpu: true);
- setState(() {
- isLoaded = true;
- });
- }
-
- Future<void> pickImage() async {
- final ImagePicker picker = ImagePicker();
- // Capture a photo
- final XFile? photo = await picker.pickImage(source: ImageSource.gallery);
- if (photo != null) {
- setState(() {
- imageFile = File(photo.path);
- });
- }
- }
-
- yoloOnImage() async {
- yoloResults.clear();
- Uint8List byte = await imageFile!.readAsBytes();
- final image = await decodeImageFromList(byte);
- imageHeight = image.height;
- imageWidth = image.width;
- final result = await widget.vision.yoloOnImage(
- bytesList: byte,
- imageHeight: image.height,
- imageWidth: image.width,
- iouThreshold: 0.8,
- confThreshold: 0.4,
- classThreshold: 0.5);
- if (result.isNotEmpty) {
- setState(() {
- yoloResults = result;
- });
- }
- }
-
- List<Widget> displayBoxesAroundRecognizedObjects(Size screen) {
- if (yoloResults.isEmpty) return [];
-
- double factorX = screen.width / (imageWidth);
- double imgRatio = imageWidth / imageHeight;
- double newWidth = imageWidth * factorX;
- double newHeight = newWidth / imgRatio;
- double factorY = newHeight / (imageHeight);
-
- double pady = (screen.height - newHeight) / 2;
-
- Color colorPick = const Color.fromARGB(255, 50, 233, 30);
- return yoloResults.map((result) {
- return Positioned(
- left: result["box"][0] * factorX,
- top: result["box"][1] * factorY + pady,
- width: (result["box"][2] - result["box"][0]) * factorX,
- height: (result["box"][3] - result["box"][1]) * factorY,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(10.0)),
- border: Border.all(color: Colors.pink, width: 2.0),
- ),
- child: Text(
- "${result['tag']} ${(result['box'][4] * 100).toStringAsFixed(0)}%",
- style: TextStyle(
- background: Paint()..color = colorPick,
- color: Colors.white,
- fontSize: 18.0,
- ),
- ),
- ),
- );
- }).toList();
- }
-}
-
-// YOLO V8 SEMANTIC SEGMENTATION
-
-class YoloImageV8Seg extends StatefulWidget {
- final FlutterVision vision;
- const YoloImageV8Seg({Key? key, required this.vision}) : super(key: key);
-
- @override
- State<YoloImageV8Seg> createState() => _YoloImageV8SegState();
-}
-
-class _YoloImageV8SegState extends State<YoloImageV8Seg> {
- late List<Map<String, dynamic>> yoloResults;
- File? imageFile;
- int imageHeight = 1;
- int imageWidth = 1;
- bool isLoaded = false;
-
- @override
- void initState() {
- super.initState();
- loadYoloModel().then((value) {
- setState(() {
- yoloResults = [];
- isLoaded = true;
- });
- });
- }
-
- @override
- void dispose() async {
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- final Size size = MediaQuery.of(context).size;
- if (!isLoaded) {
- return const Scaffold(
- body: Center(
- child: Text("Model not loaded, waiting for it"),
- ),
- );
- }
- return Stack(
- fit: StackFit.expand,
- children: [
- imageFile != null ? Image.file(imageFile!) : const SizedBox(),
- Align(
- alignment: Alignment.bottomCenter,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- TextButton(
- onPressed: pickImage,
- child: const Text("Pick image"),
- ),
- ElevatedButton(
- onPressed: yoloOnImage,
- child: const Text("Detect"),
- )
- ],
- ),
- ),
- ...displayBoxesAroundRecognizedObjects(size),
- ],
- );
- }
-
- Future<void> loadYoloModel() async {
- await widget.vision.loadYoloModel(
- labels: 'assets/labels.txt',
- modelPath: 'assets/yolov8n-seg.tflite',
- modelVersion: "yolov8seg",
- quantization: false,
- numThreads: 2,
- useGpu: true);
- setState(() {
- isLoaded = true;
- });
- }
-
- Future<void> pickImage() async {
- final ImagePicker picker = ImagePicker();
- // Capture a photo
- final XFile? photo = await picker.pickImage(source: ImageSource.gallery);
- if (photo != null) {
- setState(() {
- imageFile = File(photo.path);
- });
- }
- }
-
- yoloOnImage() async {
- yoloResults.clear();
- Uint8List byte = await imageFile!.readAsBytes();
- final image = await decodeImageFromList(byte);
- imageHeight = image.height;
- imageWidth = image.width;
- final result = await widget.vision.yoloOnImage(
- bytesList: byte,
- imageHeight: image.height,
- imageWidth: image.width,
- iouThreshold: 0.8,
- confThreshold: 0.4,
- classThreshold: 0.5);
- if (result.isNotEmpty) {
- setState(() {
- yoloResults = result;
- });
- }
- }
-
- List<Widget> displayBoxesAroundRecognizedObjects(Size screen) {
- if (yoloResults.isEmpty) return [];
-
- double factorX = screen.width / (imageWidth);
- double imgRatio = imageWidth / imageHeight;
- double newWidth = imageWidth * factorX;
- double newHeight = newWidth / imgRatio;
- double factorY = newHeight / (imageHeight);
-
- double pady = (screen.height - newHeight) / 2;
-
- Color colorPick = const Color.fromARGB(255, 50, 233, 30);
- return yoloResults.map((result) {
- return Stack(children: [
- Positioned(
- left: result["box"][0] * factorX,
- top: result["box"][1] * factorY + pady,
- width: (result["box"][2] - result["box"][0]) * factorX,
- height: (result["box"][3] - result["box"][1]) * factorY,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(10.0)),
- border: Border.all(color: Colors.pink, width: 2.0),
- ),
- child: Text(
- "${result['tag']} ${(result['box'][4] * 100).toStringAsFixed(0)}%",
- style: TextStyle(
- background: Paint()..color = colorPick,
- color: Colors.white,
- fontSize: 18.0,
- ),
- ),
- ),
- ),
- Positioned(
- left: result["box"][0] * factorX,
- top: result["box"][1] * factorY + pady,
- width: (result["box"][2] - result["box"][0]) * factorX,
- height: (result["box"][3] - result["box"][1]) * factorY,
- child: CustomPaint(
- painter: PolygonPainter(
- points: (result["polygons"] as List<dynamic>).map((e) {
- Map<String, double> xy = Map<String, double>.from(e);
- xy['x'] = (xy['x'] as double) * factorX;
- xy['y'] = (xy['y'] as double) * factorY;
- return xy;
- }).toList()),
- )),
- ]);
- }).toList();
- }
-}
-
-class PolygonPainter extends CustomPainter {
- final List<Map<String, double>> points;
-
- PolygonPainter({required this.points});
-
- @override
- void paint(Canvas canvas, Size size) {
- final paint = Paint()
- ..color = const Color.fromARGB(129, 255, 2, 124)
- ..strokeWidth = 2
- ..style = PaintingStyle.fill;
-
- final path = Path();
- if (points.isNotEmpty) {
- path.moveTo(points[0]['x']!, points[0]['y']!);
- for (var i = 1; i < points.length; i++) {
- path.lineTo(points[i]['x']!, points[i]['y']!);
- }
- path.close();
- }
-
- canvas.drawPath(path, paint);
- }
-
- @override
- bool shouldRepaint(CustomPainter oldDelegate) {
- return false;
- }
} \ No newline at end of file