I am trying to make an object detection app with Flutter mainly using the following plugins:
"tflite_flutter" https://pub.dev/packages/tflite_flutter
"camera" https://pub.dev/packages/camera
"image_picker" https://pub.dev/packages/image_picker
When I try to detect the desired object in images loaded from the assets everything works perfectly:
import 'package:image/image.dart' as img;
// load bytes
img.Image image = img.decodeImage((await rootBundle.load('assets/images/test.JPG')).buffer.asUint8List());
// my code
List<Detection> detections = ssdMobileDet.detect(image);
image = Util.drawDetections(
src: image,
detections: detections,
);
// show image in app
but when I try to use the "camera" plugin:
https://flutter.dev/docs/cookbook/plugins/picture-using-camera (full example)
String path = join(
(await getTemporaryDirectory()).path,
'${DateTime.now()}.png',
);
await _controller.takePicture(path);
img.Image image = img.decodeImage(File(path).readAsBytesSync());
or the "image_picker" plugin:
String path = (await ImagePicker().getImage(source: ImageSource.camera)).path;
img.Image image = img.decodeImage(File(path).readAsBytesSync());
on the same image the detections are useless.
I suspect that the method rootBundle.load does something different, but I could be completely wrong.