Autocalibration de la cible sur le centre de la cible ok + petite correction de la distortion mais pas tres fonctionnel
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
library;
|
||||
|
||||
import 'dart:io';
|
||||
import 'package:cunning_document_scanner/cunning_document_scanner.dart';
|
||||
import 'package:google_mlkit_document_scanner/google_mlkit_document_scanner.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import '../../core/constants/app_constants.dart';
|
||||
@@ -84,8 +84,8 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
floatingActionButton: _selectedImagePath != null
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: _analyzeImage,
|
||||
icon: const Icon(Icons.analytics),
|
||||
label: const Text('Analyser'),
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
label: const Text('Suivant'),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
@@ -205,10 +205,18 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
try {
|
||||
final List<String>? pictures = await CunningDocumentScanner.getPictures();
|
||||
final options = DocumentScannerOptions(
|
||||
documentFormat: DocumentFormat.jpeg,
|
||||
mode: ScannerMode.base,
|
||||
pageLimit: 1,
|
||||
isGalleryImport: false,
|
||||
);
|
||||
|
||||
if (pictures != null && pictures.isNotEmpty) {
|
||||
setState(() => _selectedImagePath = pictures.first);
|
||||
final scanner = DocumentScanner(options: options);
|
||||
final documents = await scanner.scanDocument();
|
||||
|
||||
if (documents.images.isNotEmpty) {
|
||||
setState(() => _selectedImagePath = documents.images.first);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
|
||||
@@ -13,20 +13,13 @@ class CropOverlay extends StatelessWidget {
|
||||
/// Afficher la grille des tiers
|
||||
final bool showGrid;
|
||||
|
||||
const CropOverlay({
|
||||
super.key,
|
||||
required this.cropSize,
|
||||
this.showGrid = true,
|
||||
});
|
||||
const CropOverlay({super.key, required this.cropSize, this.showGrid = true});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomPaint(
|
||||
size: Size.infinite,
|
||||
painter: _CropOverlayPainter(
|
||||
cropSize: cropSize,
|
||||
showGrid: showGrid,
|
||||
),
|
||||
painter: _CropOverlayPainter(cropSize: cropSize, showGrid: showGrid),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -35,10 +28,7 @@ class _CropOverlayPainter extends CustomPainter {
|
||||
final double cropSize;
|
||||
final bool showGrid;
|
||||
|
||||
_CropOverlayPainter({
|
||||
required this.cropSize,
|
||||
required this.showGrid,
|
||||
});
|
||||
_CropOverlayPainter({required this.cropSize, required this.showGrid});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
@@ -77,6 +67,9 @@ class _CropOverlayPainter extends CustomPainter {
|
||||
if (showGrid) {
|
||||
_drawGrid(canvas, cropRect);
|
||||
}
|
||||
|
||||
// Dessiner le point central (croix)
|
||||
_drawCenterPoint(canvas, cropRect);
|
||||
}
|
||||
|
||||
void _drawCorners(Canvas canvas, Rect rect) {
|
||||
@@ -171,6 +164,38 @@ class _CropOverlayPainter extends CustomPainter {
|
||||
);
|
||||
}
|
||||
|
||||
void _drawCenterPoint(Canvas canvas, Rect rect) {
|
||||
final centerPaint = Paint()
|
||||
..color = Colors.white.withValues(alpha: 0.8)
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2;
|
||||
|
||||
const size = 10.0;
|
||||
final centerX = rect.center.dx;
|
||||
final centerY = rect.center.dy;
|
||||
|
||||
// Ligne horizontale
|
||||
canvas.drawLine(
|
||||
Offset(centerX - size, centerY),
|
||||
Offset(centerX + size, centerY),
|
||||
centerPaint,
|
||||
);
|
||||
|
||||
// Ligne verticale
|
||||
canvas.drawLine(
|
||||
Offset(centerX, centerY - size),
|
||||
Offset(centerX, centerY + size),
|
||||
centerPaint,
|
||||
);
|
||||
|
||||
// Petit cercle central pour précision (optionnel, mais aide à viser)
|
||||
canvas.drawCircle(
|
||||
rect.center,
|
||||
2,
|
||||
Paint()..color = Colors.red.withValues(alpha: 0.6),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant _CropOverlayPainter oldDelegate) {
|
||||
return cropSize != oldDelegate.cropSize || showGrid != oldDelegate.showGrid;
|
||||
|
||||
Reference in New Issue
Block a user