itc_scanner 0.0.1
itc_scanner: ^0.0.1 copied to clipboard
Flutter plugin for extracting data from Ghana vehicle licensing documents using ML Kit text recognition. Simple integration for cross-platform document scanning.
ITC Scanner #
A Flutter plugin for extracting data from Ghana vehicle documents using ML Kit text recognition.
Features #
- 🚗 Extract data from Ghana vehicle licensing documents
- 📱 Cross-platform support (Android/iOS)
- 🔧 Simple integration with image bytes input
- 📊 Structured output with confidence scores
Screenshots #
iOS - Document Scanning | iOS - Extraction Results |
---|---|
[iOS Scanning] | [iOS Results] |
iOS - App Interface | Android - Full Experience |
---|---|
[iOS Interface] | [Android] |
Cross-platform support - works on both iOS and Android
Installation #
dependencies:
itc_scanner: ^0.0.1
flutter pub get
Usage #
import 'package:itc_scanner/itc_scanner.dart';
import 'dart:typed_data';
final scanner = ItcScanner();
// Extract document data from image bytes
Future<void> scanDocument(Uint8List imageBytes) async {
try {
final result = await scanner.extractDocument(imageBytes);
if (result?['success'] == true) {
final fields = result!['fields'] as List<dynamic>;
for (var field in fields) {
print('${field['label']}: ${field['value']}');
}
}
} catch (e) {
print('Error: $e');
}
}
Example with Image Picker #
import 'package:image_picker/image_picker.dart';
final picker = ImagePicker();
// Pick from camera with optimized settings
final image = await picker.pickImage(
source: ImageSource.camera,
maxWidth: 1024,
maxHeight: 1024,
imageQuality: 90,
);
if (image != null) {
final bytes = await File(image.path).readAsBytes();
await scanDocument(bytes);
}
// Pick from gallery with same optimization
final galleryImage = await picker.pickImage(
source: ImageSource.gallery,
maxWidth: 1024,
maxHeight: 1024,
imageQuality: 90,
);
Complete Example #
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:itc_scanner/itc_scanner.dart';
import 'dart:typed_data';
import 'dart:io';
class DocumentScannerWidget extends StatefulWidget {
@override
_DocumentScannerWidgetState createState() => _DocumentScannerWidgetState();
}
class _DocumentScannerWidgetState extends State<DocumentScannerWidget> {
final _scanner = ItcScanner();
final _picker = ImagePicker();
Map<String, dynamic>? _result;
bool _isLoading = false;
Future<void> _scanFromCamera() async {
final XFile? image = await _picker.pickImage(
source: ImageSource.camera,
maxWidth: 1024,
maxHeight: 1024,
imageQuality: 90,
);
if (image != null) {
await _processImage(File(image.path));
}
}
Future<void> _processImage(File imageFile) async {
setState(() => _isLoading = true);
try {
final Uint8List imageBytes = await imageFile.readAsBytes();
final result = await _scanner.extractDocument(imageBytes);
setState(() => _result = result);
} catch (e) {
print('Error: $e');
} finally {
setState(() => _isLoading = false);
}
}
@override
Widget build(BuildContext context) {
return Column(
children: [
ElevatedButton(
onPressed: _isLoading ? null : _scanFromCamera,
child: Text(_isLoading ? 'Processing...' : 'Scan Document'),
),
if (_result != null) ...[
Text('Fields found: ${(_result!['fields'] as List).length}'),
// Display your results here
],
],
);
}
}
Response Format #
{
"success": true,
"documentType": "VEHICLE_REGISTRATION",
"processingTime": 1250,
"fields": [
{
"label": "Document Number",
"value": "GB 5803-12",
"confidence": 0.95,
"fieldType": "ID_NUMBER"
},
{
"label": "Document ID",
"value": "A371750335192",
"confidence": 0.85,
"fieldType": "ID_NUMBER"
},
{
"label": "Make",
"value": "TOYOTA",
"confidence": 0.90,
"fieldType": "TEXT"
},
{
"label": "Model",
"value": "COROLLA",
"confidence": 0.90,
"fieldType": "TEXT"
},
{
"label": "Color",
"value": "WHITE",
"confidence": 0.90,
"fieldType": "TEXT"
},
{
"label": "Use",
"value": "PRIVATE",
"confidence": 0.90,
"fieldType": "TEXT"
},
{
"label": "Expiry Date",
"value": "2026-06-19",
"confidence": 0.90,
"fieldType": "DATE"
}
]
}
Requirements #
- Android: API 24+
- iOS: 15.5+
- Flutter: 3.3.0+
Field Types #
TEXT
: General text (Make, Model, Color)ID_NUMBER
: Document identifiersDATE
: Date fieldsNUMBER
: Numeric values
Tips #
- Use good lighting when capturing documents
- Keep document flat and properly aligned
- Optimize image size: Use
maxWidth: 1024, maxHeight: 1024, imageQuality: 90
for better performance - Recommended image size: 1024x1024 or higher (but not too large)
- Smaller images = faster processing and better app performance
Support #
ITC Consortium Ghana
Email: info@itconsortiumgh.com
License #
Proprietary - Internal use only