My task is to create an app, which gives the opportunity to user to take a shot from mobile camera or pick a photo from gallery, export photo's geotag, and on the next step I would like to add a button which will convert these coords from mobiles datum (WGS84) to my country's datum which is EGSA87. I know it's hard for a newbie user but I'll try:'D
At the moment I finished the part of image capturing and image selection from the gallery.
I found some packages like exif, geolocation etc. but I need some help to apply them: P
The code is the following.
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:tflite/tflite.dart';
import 'package:image_picker/image_picker.dart';
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
bool _loading = true;
File _image;
List _output;
final picker = ImagePicker();
detectImage(File image) async {
var output = await Tflite.runModelOnImage(
path: image.path,
numResults: 2,
threshold: 0.6,
imageMean: 127.5,
imageStd: 127.5
);
setState(() {
_output = output;
_loading = false;
});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
pickImage()async{
var image = await picker.getImage(source: ImageSource.camera);
if(image == null) return null;
setState(() {
_image = File(image.path);
});
detectImage(_image);
}
pickGalleryImage()async{
var image = await picker.getImage(source: ImageSource.gallery);
if(image == null) return null;
setState(() {
_image = File(image.path);
});
detectImage(_image);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueAccent,
body: Container(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Column(crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: 40),
Text('Coords Converter App',
style: TextStyle(color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 30),
),
SizedBox(height: 5),
Text('',
style: TextStyle(color: Colors.white,
fontSize: 10),
),
SizedBox(height: 50),
Center(child: _loading ?
Container(
width: 350,
child: Column(children: <Widget>[
Image.asset('assets/new.png'),
SizedBox(height: 50),
],),
) : Container(
child: Column(children: <Widget>[
Container(
height: 250,
child: Image.file(_image),
),
SizedBox(height: 20),
_output != null
? Text('${_output[0]['label']}',
style: TextStyle(
color: Colors.white,
fontSize: 15
),
)
: Container(),
SizedBox(height: 10),
],),
),
),
Container(
width: MediaQuery.of(context).size.width,
child: Column(
children: <Widget>[
GestureDetector(
onTap: (){
pickImage();
},
child: Container(
width: MediaQuery.of(context).size.width - 250,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 18),
decoration: BoxDecoration(
color: Colors.redAccent,
borderRadius: BorderRadius.circular(6),
),
child: Text(
'Capture a Photo',
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
),
SizedBox(height: 5),
GestureDetector(
onTap: (){
pickGalleryImage();
},
child: Container(
width: MediaQuery.of(context).size.width - 250,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 18),
decoration: BoxDecoration(
color: Colors.redAccent,
borderRadius: BorderRadius.circular(6),
),
child: Text(
'Select a photo',
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
),
],),
),
],
)
)
);
}
}