flutter_tensorflow_lite 1.0.1 copy "flutter_tensorflow_lite: ^1.0.1" to clipboard
flutter_tensorflow_lite: ^1.0.1 copied to clipboard

A Flutter plugin for accessing TensorFlow Lite. Supports both iOS and Android.

example/lib/main.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:example/blur_detector.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Blur Detector Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const BlurDetectorScreen(),
    );
  }
}

class BlurDetectorScreen extends StatefulWidget {
  const BlurDetectorScreen({Key? key}) : super(key: key);

  @override
  _BlurDetectorScreenState createState() => _BlurDetectorScreenState();
}

class _BlurDetectorScreenState extends State<BlurDetectorScreen> {
  final ImagePicker _picker = ImagePicker();
  File? _image;
  String _result = '';

  Future<void> _pickImage() async {
    final XFile? image = await _picker.pickImage(source: ImageSource.gallery);

    if (image != null) {
      setState(() {
        _image = File(image.path);
        _result = '';
      });

      final bool isImageClear = await BlurRadio.evaluateImageQuality(
        image: File(image.path),
        acceptableBlurThreshold: 45,
      );

      setState(() {
        _result = isImageClear
            ? "The image is clear and readable."
            : "The image is blurry or text is not readable.";
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Blur Detector Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            if (_image != null) Image.file(_image!,height: 500),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: _pickImage,
              child: const Text('Pick an Image'),
            ),
            const SizedBox(height: 20),
            Text(
              _result,
              style: const TextStyle(fontSize: 18),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
0
points
216
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for accessing TensorFlow Lite. Supports both iOS and Android.

License

unknown (license)

Dependencies

flutter, meta

More

Packages that depend on flutter_tensorflow_lite

Packages that implement flutter_tensorflow_lite