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:
2026-02-15 09:49:48 +01:00
parent f78184d2cd
commit 723900b860
7 changed files with 288 additions and 102 deletions

View File

@@ -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;