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