detector_blur_image 0.1.0
detector_blur_image: ^0.1.0 copied to clipboard
A Flutter package that provides utilities for detecting blur in images. Ideal for applications that require image quality analysis.
example/lib/main.dart
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:detector_blur_image/blur_detector.dart';
import 'package:cunning_document_scanner/cunning_document_scanner.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({super.key});
@override
_BlurDetectorScreenState createState() => _BlurDetectorScreenState();
}
class _BlurDetectorScreenState extends State<BlurDetectorScreen> {
File? _image;
String _result = '';
Future<void> _pickImage() async {
List<String> pictures = await CunningDocumentScanner.getPictures(
noOfPages: 1, isGalleryImportAllowed: true) ??
[];
if (pictures.isNotEmpty) {
String path = pictures[0];
setState(() {
_image = File(path);
_result = '';
});
final bool isImageClear = await BlurRadio.evaluateImageQuality(
imagePath: path,
acceptableBlurThreshold: 60,
);
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),
),
],
),
),
);
}
}