Commit 8f88754f authored by Dasun Madushanka's avatar Dasun Madushanka

Update dmt_crash.dart

parent 0b75b698
...@@ -6,7 +6,7 @@ import 'package:image_picker/image_picker.dart'; ...@@ -6,7 +6,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:tflite/tflite.dart'; import 'package:tflite/tflite.dart';
class DMTCrash extends StatefulWidget { class DMTCrash extends StatefulWidget {
static const routeName = "dmt_crash"; static const routeName = "dmt_crash";//add route,connect with product
@override @override
_DMTCrashState createState() => _DMTCrashState(); _DMTCrashState createState() => _DMTCrashState();
} }
...@@ -27,7 +27,7 @@ class _DMTCrashState extends State<DMTCrash> { ...@@ -27,7 +27,7 @@ class _DMTCrashState extends State<DMTCrash> {
}); });
}); });
} }
//test results page
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -52,6 +52,7 @@ class _DMTCrashState extends State<DMTCrash> { ...@@ -52,6 +52,7 @@ class _DMTCrashState extends State<DMTCrash> {
: Container( : Container(
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: Column( child: Column(
//add paddings
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
...@@ -64,7 +65,7 @@ class _DMTCrashState extends State<DMTCrash> { ...@@ -64,7 +65,7 @@ class _DMTCrashState extends State<DMTCrash> {
"${_outputs[0]["label"]}", "${_outputs[0]["label"]}",
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 20.0, fontSize: 20.0,//font size int text feild
background: Paint()..color = Colors.white, background: Paint()..color = Colors.white,
), ),
) )
...@@ -72,13 +73,14 @@ class _DMTCrashState extends State<DMTCrash> { ...@@ -72,13 +73,14 @@ class _DMTCrashState extends State<DMTCrash> {
], ],
), ),
), ),
//using the floating action button can select the images from gallery
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: pickImage, onPressed: pickImage,
child: Icon(Icons.image), child: Icon(Icons.image),
), ),
); );
} }
//add images from gallery
pickImage() async { pickImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery); var image = await ImagePicker.pickImage(source: ImageSource.gallery);
if (image == null) return null; if (image == null) return null;
...@@ -88,7 +90,7 @@ class _DMTCrashState extends State<DMTCrash> { ...@@ -88,7 +90,7 @@ class _DMTCrashState extends State<DMTCrash> {
}); });
classifyImage(image); classifyImage(image);
} }
//classify the image we took
classifyImage(File image) async { classifyImage(File image) async {
var output = await Tflite.runModelOnImage( var output = await Tflite.runModelOnImage(
path: image.path, path: image.path,
...@@ -102,7 +104,8 @@ class _DMTCrashState extends State<DMTCrash> { ...@@ -102,7 +104,8 @@ class _DMTCrashState extends State<DMTCrash> {
_outputs = output; _outputs = output;
}); });
} }
//add model to assesst folder
//detect the object with model
loadModel() async { loadModel() async {
await Tflite.loadModel( await Tflite.loadModel(
model: "assets/model_unquant.tflite", model: "assets/model_unquant.tflite",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment