Compare commits
10 Commits
v0.0.1
...
2e81f4b69e
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e81f4b69e | |||
| de677aad7e | |||
| 723900b860 | |||
| f78184d2cd | |||
| 7e55c52ae7 | |||
| 049f77ac6d | |||
| 91fcd931e8 | |||
| 9ccb149dda | |||
| 972474750f | |||
| 2f69ff4ecf |
25
CHANGELOG.md
Normal file
25
CHANGELOG.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Changelog
|
||||
|
||||
## [v0.0.1] - 2026-01-29
|
||||
|
||||
### Ajouté
|
||||
- **Interface d'Analyse** :
|
||||
- Implémentation d'un bouton de sauvegarde "Morphing" : le bouton flottant se transforme en un bouton large en bas de page lors du défilement.
|
||||
- Ajout de la gestion du défilement et de l'espacement pour une meilleure ergonomie.
|
||||
- Visualisation des impacts et statistiques de groupement.
|
||||
- **Support Desktop (Windows)** :
|
||||
- Configuration de la base de données SQLite pour fonctionner sur Windows via `sqflite_common_ffi`.
|
||||
- Initialisation conditionnelle selon la plateforme.
|
||||
|
||||
### Corrigé
|
||||
- **Crash Windows** : Résolution du plantage dû à l'initialisation manquante de la factory de base de données FFI.
|
||||
- **Dépendances** : Fixation de la version de `sqflite_common_ffi` à `2.3.3` pour contourner un problème de cache/corruption avec la version `2.4.0+2`.
|
||||
- **UI/UX** :
|
||||
- Correction des débordements de texte ("zebra stripes") dans le bouton de sauvegarde lors de l'animation grâce à `FittedBox`.
|
||||
- Optimisation de l'affichage du titre "Groupement" dans les statistiques pour éviter les dépassements sur petits écrans.
|
||||
- Nettoyage des appels redondants (`super.initState`) et correction de la structure des widgets (`Stack` mal fermé).
|
||||
|
||||
### Historique des Commits
|
||||
- `db7160b` - +désactivation (2026-01-29)
|
||||
- `f1a8eef` - ajout correctif (2026-01-28)
|
||||
- `031d4a4` - premier app version beta (2026-01-18)
|
||||
40
README.md
40
README.md
@@ -1,17 +1,35 @@
|
||||
# bully
|
||||
# Bully - Analyseur de Cible
|
||||
|
||||
A new Flutter project.
|
||||
Application Flutter multiplateforme pour l'analyse et le suivi de vos séances de tir.
|
||||
|
||||
## Getting Started
|
||||
## Fonctionnalités Principales
|
||||
|
||||
This project is a starting point for a Flutter application.
|
||||
* **Capture et Analyse** : Prenez une photo de votre cible et analysez vos impacts.
|
||||
* **Détection Automatique** : Utilise des algorithmes pour détecter automatiquement les impacts de balle sur la cible.
|
||||
* **Calibration** : Outils de calibration précis pour définir la taille et le centre de la cible, assurant des mesures exactes.
|
||||
* **Statistiques Détaillées** :
|
||||
* Calcul du score total.
|
||||
* Analyse du groupement (H+L, diamètre moyen).
|
||||
* Visualisation graphique de la dispersion.
|
||||
* **Historique** : Sauvegardez vos sessions avec des notes et consultez votre progression au fil du temps.
|
||||
* **Interface Intuitive** : Design moderne et fluide, avec un bouton de sauvegarde dynamique qui s'adapte à votre navigation.
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
## Détails Techniques
|
||||
|
||||
- [Learn Flutter](https://docs.flutter.dev/get-started/learn-flutter)
|
||||
- [Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
||||
- [Flutter learning resources](https://docs.flutter.dev/reference/learning-resources)
|
||||
* **Framework** : Flutter (Compatible Android, iOS, Windows, Linux, macOS).
|
||||
* **Base de Données** : SQLite (via `sqflite` et `sqflite_common_ffi` pour le support Desktop).
|
||||
* **Graphiques** : `fl_chart` pour la visualisation des données.
|
||||
* **Architecture** : Provider pour la gestion d'état.
|
||||
|
||||
For help getting started with Flutter development, view the
|
||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
## Installation
|
||||
|
||||
1. Assurez-vous d'avoir Flutter installé.
|
||||
2. Clonez le dépôt.
|
||||
3. Installez les dépendances :
|
||||
```bash
|
||||
flutter pub get
|
||||
```
|
||||
4. Lancez l'application :
|
||||
```bash
|
||||
flutter run
|
||||
```
|
||||
|
||||
31
analyze_log.txt
Normal file
31
analyze_log.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
Analyzing bully...
|
||||
|
||||
info - Statements in an if should be enclosed in a block - lib\features\analysis\analysis_screen.dart:122:17 - curly_braces_in_flow_control_structures
|
||||
info - 'withOpacity' is deprecated and shouldn't be used. Use .withValues() to avoid precision loss - lib\features\analysis\analysis_screen.dart:650:51 - deprecated_member_use
|
||||
warning - The declaration '_showAddShotHint' isn't referenced - lib\features\analysis\analysis_screen.dart:1083:8 - unused_element
|
||||
warning - The declaration '_showAutoDetectDialog' isn't referenced - lib\features\analysis\analysis_screen.dart:1120:8 - unused_element
|
||||
warning - Unused import: 'widgets/target_type_selector.dart' - lib\features\capture\capture_screen.dart:16:8 - unused_import
|
||||
info - The private field _selectedType could be 'final' - lib\features\capture\capture_screen.dart:28:14 - prefer_final_fields
|
||||
info - 'scale' is deprecated and shouldn't be used. Use scaleByVector3, scaleByVector4, or scaleByDouble instead - lib\features\crop\crop_screen.dart:141:25 - deprecated_member_use
|
||||
info - The import of 'package:flutter/foundation.dart' is unnecessary because all of the used elements are also provided by the import of 'package:flutter/material.dart' - lib\features\statistics\statistics_screen.dart:8:8 - unnecessary_import
|
||||
warning - The declaration '_buildLegendItem' isn't referenced - lib\features\statistics\statistics_screen.dart:309:10 - unused_element
|
||||
info - Unnecessary use of string interpolation - lib\features\statistics\statistics_screen.dart:408:15 - unnecessary_string_interpolations
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:192:7 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:239:7 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:246:9 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:278:9 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:289:11 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:292:11 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:297:9 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:332:7 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:336:7 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:683:7 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:725:7 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\image_processing_service.dart:736:7 - avoid_print
|
||||
warning - The declaration '_detectDarkSpotsAdaptive' isn't referenced - lib\services\image_processing_service.dart:780:15 - unused_element
|
||||
info - Don't invoke 'print' in production code - lib\services\opencv_impact_detection_service.dart:104:5 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\opencv_impact_detection_service.dart:116:5 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\target_detection_service.dart:297:7 - avoid_print
|
||||
info - Don't invoke 'print' in production code - lib\services\target_detection_service.dart:342:7 - avoid_print
|
||||
|
||||
27 issues found. (ran in 1.9s)
|
||||
BIN
analyze_opencv.txt
Normal file
BIN
analyze_opencv.txt
Normal file
Binary file not shown.
@@ -1,4 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<application
|
||||
android:label="bully"
|
||||
android:name="${applicationName}"
|
||||
|
||||
20
build_log.txt
Normal file
20
build_log.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
Running Gradle task 'assembleDebug'...
|
||||
|
||||
FAILURE: Build failed with an exception.
|
||||
|
||||
* What went wrong:
|
||||
Execution failed for task ':app:processDebugResources'.
|
||||
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
|
||||
> Android resource linking failed
|
||||
ERROR: C:\Users\streaper2\Documents\00 - projet\bully\build\cunning_document_scanner\intermediates\merged_manifest\debug\processDebugManifest\AndroidManifest.xml:9:5-65: AAPT: error: unexpected element <uses-permission> found in <manifest><application>.
|
||||
|
||||
|
||||
* Try:
|
||||
> Run with --stacktrace option to get the stack trace.
|
||||
> Run with --info or --debug option to get more log output.
|
||||
> Run with --scan to get full insights.
|
||||
> Get more help at https://help.gradle.org.
|
||||
|
||||
BUILD FAILED in 5s
|
||||
Running Gradle task 'assembleDebug'... 5,4s
|
||||
Gradle task assembleDebug failed with exit code 1
|
||||
3
devtools_options.yaml
Normal file
3
devtools_options.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
description: This file stores settings for Dart & Flutter DevTools.
|
||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||
extensions:
|
||||
26
docs/README.md
Normal file
26
docs/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Documentation du Projet Bully
|
||||
|
||||
Bienvenue dans la documentation développeur de l'application **Bully**.
|
||||
|
||||
Ce projet est une application Flutter d'analyse de cibles de tir (Impact Detection).
|
||||
|
||||
## Architecture
|
||||
|
||||
Le code source est organisé dans le dossier `lib/` selon les couches suivantes :
|
||||
|
||||
- **Features (`lib/features`)** : Contient les écrans et la logique UI (Vues/Pages). C'est ici que réside l'interface utilisateur.
|
||||
- **Services (`lib/services`)** : Services "métier" et utilitaires (traitement d'image, calculs, etc.). Indépendant de l'UI.
|
||||
- **Data (`lib/data`)** : Gestion des données (Modèles, Base de données locale, Repositories).
|
||||
|
||||
## Sections de la Documentation
|
||||
|
||||
Pour plus de détails sur chaque partie, consultez les sections dédiées :
|
||||
|
||||
- 🏗️ **[Services (Logique Métier)](services/README.md)** : Documentation des services comme le traitement d'image et le calcul de score.
|
||||
- 📱 **[Vues & Features (UI)](features/README.md)** : Documentation des écrans principaux (ex: Analyse).
|
||||
- 💾 **[Base de Données & Modèles](data/README.md)** : Structure des données et persistance.
|
||||
|
||||
## Pour commencer
|
||||
|
||||
1. Assurez-vous d'avoir Flutter installé.
|
||||
2. Lancez `flutter run` pour démarrer l'application.
|
||||
17
docs/data/README.md
Normal file
17
docs/data/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Data & Persistance
|
||||
|
||||
Cette couche gère la sauvegarde et la récupération des données.
|
||||
|
||||
## Base de Données
|
||||
L'application utilise une base de données locale (probablement SQLite/Drift ou Hive, à vérifier dans `lib/data/database`).
|
||||
|
||||
## Modèles (`lib/data/models`)
|
||||
Les classes représentant les objets métier persistés.
|
||||
|
||||
Exemples probables :
|
||||
- `Session` : Une session de tir.
|
||||
- `Impact` : Un impact de balle sur la cible.
|
||||
- `Target` : Configuration d'une cible.
|
||||
|
||||
## Repositories (`lib/data/repositories`)
|
||||
Le pattern Repository est utilisé pour abstraire la source de données (DB locale, API distante, etc.) du reste de l'application.
|
||||
17
docs/features/README.md
Normal file
17
docs/features/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Features & Vues
|
||||
|
||||
Cette section documente les écrans principaux de l'application et leur organisation.
|
||||
|
||||
## Écrans Principaux
|
||||
|
||||
### Analysis (`lib/features/analysis`)
|
||||
C'est le cœur de l'application. Il permet à l'utilisateur de prendre une photo ou choisir une image pour analyser les impacts.
|
||||
|
||||
- **AnalysisScreen** (`analysis_screen.dart`): L'écran principal qui orchestre la capture et l'affichage des résultats.
|
||||
- **AnalysisProvider** (`analysis_provider.dart`): Gestionnaire d'état (State Management) pour cet écran. Il fait le pont entre la vue et les services.
|
||||
|
||||
## Structure d'une Feature
|
||||
Chaque feature est généralement composée de :
|
||||
- `_screen.dart` : Le Widget de la page.
|
||||
- `_provider.dart` : La logique d'état (ChangeNotifier, Bloc, etc.).
|
||||
- `widgets/` : Widgets spécifiques à cette feature.
|
||||
20
docs/services/README.md
Normal file
20
docs/services/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Services
|
||||
|
||||
Les services contiennent la logique métier de l'application, isolée de l'interface utilisateur.
|
||||
|
||||
## Liste des Services Principaux
|
||||
|
||||
| Service | Description | Fichier |
|
||||
| :--- | :--- | :--- |
|
||||
| **ImageProcessingService** | Gère le traitement lourd des images (filtres, détection). | `lib/services/image_processing_service.dart` |
|
||||
| **DistortionCorrection** | Corrige la distorsion de perspective des cibles. | `lib/services/distortion_correction_service.dart` |
|
||||
| **ScoreCalculator** | Calcule le score en fonction des impacts détectés. | `lib/services/score_calculator_service.dart` |
|
||||
| **StatisticsService** | Génère des statistiques sur les sessions de tir. | `lib/services/statistics_service.dart` |
|
||||
|
||||
## Exemple d'utilisation (Fictif)
|
||||
|
||||
```dart
|
||||
// Exemple d'appel au service de calcul de score
|
||||
final calculator = ScoreCalculatorService();
|
||||
final score = calculator.calculate(impacts);
|
||||
```
|
||||
@@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>This app needs camera access to scan documents</string>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
|
||||
@@ -17,6 +17,7 @@ import '../../services/target_detection_service.dart';
|
||||
import '../../services/score_calculator_service.dart';
|
||||
import '../../services/grouping_analyzer_service.dart';
|
||||
import '../../services/distortion_correction_service.dart';
|
||||
import '../../services/opencv_target_service.dart';
|
||||
|
||||
enum AnalysisState { initial, loading, success, error }
|
||||
|
||||
@@ -26,6 +27,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
final GroupingAnalyzerService _groupingAnalyzerService;
|
||||
final SessionRepository _sessionRepository;
|
||||
final DistortionCorrectionService _distortionService;
|
||||
final OpenCVTargetService _opencvTargetService;
|
||||
final Uuid _uuid = const Uuid();
|
||||
|
||||
AnalysisProvider({
|
||||
@@ -34,11 +36,13 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
required GroupingAnalyzerService groupingAnalyzerService,
|
||||
required SessionRepository sessionRepository,
|
||||
DistortionCorrectionService? distortionService,
|
||||
OpenCVTargetService? opencvTargetService,
|
||||
}) : _detectionService = detectionService,
|
||||
_scoreCalculatorService = scoreCalculatorService,
|
||||
_groupingAnalyzerService = groupingAnalyzerService,
|
||||
_sessionRepository = sessionRepository,
|
||||
_distortionService = distortionService ?? DistortionCorrectionService();
|
||||
_distortionService = distortionService ?? DistortionCorrectionService(),
|
||||
_opencvTargetService = opencvTargetService ?? OpenCVTargetService();
|
||||
|
||||
AnalysisState _state = AnalysisState.initial;
|
||||
String? _errorMessage;
|
||||
@@ -80,7 +84,8 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
double get targetCenterY => _targetCenterY;
|
||||
double get targetRadius => _targetRadius;
|
||||
int get ringCount => _ringCount;
|
||||
List<double>? get ringRadii => _ringRadii != null ? List.unmodifiable(_ringRadii!) : null;
|
||||
List<double>? get ringRadii =>
|
||||
_ringRadii != null ? List.unmodifiable(_ringRadii!) : null;
|
||||
double get imageAspectRatio => _imageAspectRatio;
|
||||
List<Shot> get shots => List.unmodifiable(_shots);
|
||||
ScoreResult? get scoreResult => _scoreResult;
|
||||
@@ -97,13 +102,22 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
DistortionParameters? get distortionParams => _distortionParams;
|
||||
String? get correctedImagePath => _correctedImagePath;
|
||||
bool get hasDistortion => _distortionParams?.needsCorrection ?? false;
|
||||
|
||||
/// Retourne le chemin de l'image à afficher (corrigée si activée, originale sinon)
|
||||
String? get displayImagePath => _distortionCorrectionEnabled && _correctedImagePath != null
|
||||
String? get displayImagePath =>
|
||||
_distortionCorrectionEnabled && _correctedImagePath != null
|
||||
? _correctedImagePath
|
||||
: _imagePath;
|
||||
|
||||
/// Analyze an image
|
||||
Future<void> analyzeImage(String imagePath, TargetType targetType) async {
|
||||
///
|
||||
/// [autoAnalyze] determines if we should run automatic detection immediately.
|
||||
/// If false, only the image is loaded and default target parameters are set.
|
||||
Future<void> analyzeImage(
|
||||
String imagePath,
|
||||
TargetType targetType, {
|
||||
bool autoAnalyze = true,
|
||||
}) async {
|
||||
_state = AnalysisState.loading;
|
||||
_imagePath = imagePath;
|
||||
_targetType = targetType;
|
||||
@@ -119,6 +133,20 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
_imageAspectRatio = frame.image.width / frame.image.height;
|
||||
frame.image.dispose();
|
||||
|
||||
if (!autoAnalyze) {
|
||||
// Just setup default values without running detection
|
||||
_targetCenterX = 0.5;
|
||||
_targetCenterY = 0.5;
|
||||
_targetRadius = 0.4;
|
||||
|
||||
// Initialize empty shots list
|
||||
_shots = [];
|
||||
|
||||
_state = AnalysisState.success;
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
|
||||
// Detect target and impacts
|
||||
final result = _detectionService.detectTarget(imagePath, targetType);
|
||||
|
||||
@@ -162,13 +190,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
/// Add a manual shot
|
||||
void addShot(double x, double y) {
|
||||
final score = _calculateShotScore(x, y);
|
||||
final shot = Shot(
|
||||
id: _uuid.v4(),
|
||||
x: x,
|
||||
y: y,
|
||||
score: score,
|
||||
sessionId: '',
|
||||
);
|
||||
final shot = Shot(id: _uuid.v4(), x: x, y: y, score: score, sessionId: '');
|
||||
|
||||
_shots.add(shot);
|
||||
_recalculateScores();
|
||||
@@ -190,11 +212,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
if (index == -1) return;
|
||||
|
||||
final newScore = _calculateShotScore(newX, newY);
|
||||
_shots[index] = _shots[index].copyWith(
|
||||
x: newX,
|
||||
y: newY,
|
||||
score: newScore,
|
||||
);
|
||||
_shots[index] = _shots[index].copyWith(x: newX, y: newY, score: newScore);
|
||||
|
||||
_recalculateScores();
|
||||
_recalculateGrouping();
|
||||
@@ -334,7 +352,9 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
double tolerance = 2.0,
|
||||
bool clearExisting = false,
|
||||
}) async {
|
||||
if (_imagePath == null || _targetType == null || _referenceImpacts.length < 2) {
|
||||
if (_imagePath == null ||
|
||||
_targetType == null ||
|
||||
_referenceImpacts.length < 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -343,7 +363,8 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
.map((shot) => ReferenceImpact(x: shot.x, y: shot.y))
|
||||
.toList();
|
||||
|
||||
final detectedImpacts = _detectionService.detectImpactsWithOpenCVFromReferences(
|
||||
final detectedImpacts = _detectionService
|
||||
.detectImpactsWithOpenCVFromReferences(
|
||||
_imagePath!,
|
||||
_targetType!,
|
||||
_targetCenterX,
|
||||
@@ -381,13 +402,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
/// Add a reference impact for calibrated detection
|
||||
void addReferenceImpact(double x, double y) {
|
||||
final score = _calculateShotScore(x, y);
|
||||
final shot = Shot(
|
||||
id: _uuid.v4(),
|
||||
x: x,
|
||||
y: y,
|
||||
score: score,
|
||||
sessionId: '',
|
||||
);
|
||||
final shot = Shot(id: _uuid.v4(), x: x, y: y, score: score, sessionId: '');
|
||||
_referenceImpacts.add(shot);
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -428,7 +443,9 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
double tolerance = 2.0,
|
||||
bool clearExisting = false,
|
||||
}) async {
|
||||
if (_imagePath == null || _targetType == null || _learnedCharacteristics == null) {
|
||||
if (_imagePath == null ||
|
||||
_targetType == null ||
|
||||
_learnedCharacteristics == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -468,7 +485,13 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
/// Adjust target position
|
||||
void adjustTargetPosition(double centerX, double centerY, double radius, {int? ringCount, List<double>? ringRadii}) {
|
||||
void adjustTargetPosition(
|
||||
double centerX,
|
||||
double centerY,
|
||||
double radius, {
|
||||
int? ringCount,
|
||||
List<double>? ringRadii,
|
||||
}) {
|
||||
_targetCenterX = centerX;
|
||||
_targetCenterY = centerY;
|
||||
_targetRadius = radius;
|
||||
@@ -489,6 +512,24 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Auto-calibrate target using OpenCV
|
||||
Future<bool> autoCalibrateTarget() async {
|
||||
if (_imagePath == null) return false;
|
||||
|
||||
try {
|
||||
final result = await _opencvTargetService.detectTarget(_imagePath!);
|
||||
|
||||
if (result.success) {
|
||||
adjustTargetPosition(result.centerX, result.centerY, result.radius);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
print('Auto-calibration error: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Calcule les paramètres de distorsion basés sur la calibration actuelle
|
||||
void calculateDistortion() {
|
||||
_distortionParams = _distortionService.calculateDistortionFromCalibration(
|
||||
@@ -529,8 +570,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* version deux a tester*/
|
||||
/* version deux a tester*/
|
||||
/// Calcule ET applique la correction pour un feedback immédiat
|
||||
Future<void> calculateAndApplyDistortion() async {
|
||||
// 1. Calcul des paramètres (votre code actuel)
|
||||
@@ -566,7 +606,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
/* fin section deux a tester*/
|
||||
/* fin section deux a tester*/
|
||||
|
||||
int _calculateShotScore(double x, double y) {
|
||||
if (_targetType == TargetType.concentric) {
|
||||
|
||||
@@ -39,7 +39,7 @@ class AnalysisScreen extends StatelessWidget {
|
||||
scoreCalculatorService: context.read<ScoreCalculatorService>(),
|
||||
groupingAnalyzerService: context.read<GroupingAnalyzerService>(),
|
||||
sessionRepository: context.read<SessionRepository>(),
|
||||
)..analyzeImage(imagePath, targetType),
|
||||
)..analyzeImage(imagePath, targetType, autoAnalyze: false),
|
||||
child: const _AnalysisScreenContent(),
|
||||
);
|
||||
}
|
||||
@@ -58,7 +58,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
bool _isFullscreenEditMode = false;
|
||||
bool _isAtBottom = false;
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
final TransformationController _transformationController = TransformationController();
|
||||
final TransformationController _transformationController =
|
||||
TransformationController();
|
||||
final GlobalKey _imageKey = GlobalKey();
|
||||
double _currentZoomScale = 1.0;
|
||||
|
||||
@@ -72,7 +73,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
void _onScroll() {
|
||||
if (!_scrollController.hasClients) return;
|
||||
// Detect if we are near the bottom (within 20 pixels of the specific spacing we added)
|
||||
final isBottom = _scrollController.position.pixels >= _scrollController.position.maxScrollExtent - 20;
|
||||
final isBottom =
|
||||
_scrollController.position.pixels >=
|
||||
_scrollController.position.maxScrollExtent - 20;
|
||||
if (isBottom != _isAtBottom) {
|
||||
setState(() {
|
||||
_isAtBottom = isBottom;
|
||||
@@ -115,13 +118,17 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
actions: [
|
||||
Consumer<AnalysisProvider>(
|
||||
builder: (context, provider, _) {
|
||||
if (provider.state != AnalysisState.success) return const SizedBox.shrink();
|
||||
if (provider.state != AnalysisState.success) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return IconButton(
|
||||
icon: Icon(_isCalibrating ? Icons.check : Icons.tune),
|
||||
onPressed: () {
|
||||
setState(() => _isCalibrating = !_isCalibrating);
|
||||
},
|
||||
tooltip: _isCalibrating ? 'Terminer calibration' : 'Calibrer la cible',
|
||||
tooltip: _isCalibrating
|
||||
? 'Terminer calibration'
|
||||
: 'Calibrer la cible',
|
||||
color: _isCalibrating ? AppTheme.successColor : null,
|
||||
);
|
||||
},
|
||||
@@ -155,7 +162,11 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.error_outline, size: 64, color: AppTheme.errorColor),
|
||||
Icon(
|
||||
Icons.error_outline,
|
||||
size: 64,
|
||||
color: AppTheme.errorColor,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
provider.errorMessage ?? 'Une erreur est survenue',
|
||||
@@ -195,7 +206,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
if (_isCalibrating)
|
||||
Container(
|
||||
color: AppTheme.warningColor,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 16,
|
||||
),
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.tune, color: Colors.white, size: 20),
|
||||
@@ -203,7 +217,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Mode Calibration - Ajustez le centre et la taille de la cible',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -214,21 +231,34 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
if (_isSelectingReferences)
|
||||
Container(
|
||||
color: Colors.deepPurple,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 16,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.touch_app, color: Colors.white, size: 20),
|
||||
const Icon(
|
||||
Icons.touch_app,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Selectionnez ${provider.referenceImpacts.length}/3-4 impacts de reference',
|
||||
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (provider.referenceImpacts.isNotEmpty)
|
||||
TextButton(
|
||||
onPressed: () => provider.clearReferenceImpacts(),
|
||||
child: const Text('Effacer', style: TextStyle(color: Colors.white)),
|
||||
child: const Text(
|
||||
'Effacer',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -238,15 +268,87 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
if (_isCalibrating)
|
||||
Container(
|
||||
color: Colors.black87,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Auto-calibrate button
|
||||
/*SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () async {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Text('Auto-calibration en cours...'),
|
||||
],
|
||||
),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
|
||||
final success = await provider
|
||||
.autoCalibrateTarget();
|
||||
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).hideCurrentSnackBar();
|
||||
if (success) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'Cible calibrée automatiquement',
|
||||
),
|
||||
backgroundColor: AppTheme.successColor,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'Échec de la calibration auto',
|
||||
),
|
||||
backgroundColor: AppTheme.errorColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.auto_fix_high),
|
||||
label: const Text('Auto-Calibrer la Cible'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.deepPurple,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
),*/
|
||||
const SizedBox(height: 16),
|
||||
// Ring count slider
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.radio_button_unchecked, color: Colors.white, size: 20),
|
||||
const Icon(
|
||||
Icons.radio_button_unchecked,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Anneaux:', style: TextStyle(color: Colors.white)),
|
||||
const Text(
|
||||
'Anneaux:',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: provider.ringCount.toDouble(),
|
||||
@@ -266,14 +368,20 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.primaryColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'${provider.ringCount}',
|
||||
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -281,15 +389,23 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
// Target size slider
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.zoom_out_map, color: Colors.white, size: 20),
|
||||
const Icon(
|
||||
Icons.zoom_out_map,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Taille:', style: TextStyle(color: Colors.white)),
|
||||
const Text(
|
||||
'Taille:',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: provider.targetRadius.clamp(0.05, 3.0),
|
||||
min: 0.05,
|
||||
max: 3.0,
|
||||
label: '${(provider.targetRadius * 100).toStringAsFixed(0)}%',
|
||||
label:
|
||||
'${(provider.targetRadius * 100).toStringAsFixed(0)}%',
|
||||
activeColor: AppTheme.warningColor,
|
||||
onChanged: (value) {
|
||||
provider.adjustTargetPosition(
|
||||
@@ -302,26 +418,39 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.warningColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'${(provider.targetRadius * 100).toStringAsFixed(0)}%',
|
||||
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(color: Colors.white24, height: 16),
|
||||
// Distortion correction row
|
||||
Row(
|
||||
/*Row(
|
||||
children: [
|
||||
const Icon(Icons.lens_blur, color: Colors.white, size: 20),
|
||||
const Icon(
|
||||
Icons.lens_blur,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Expanded(
|
||||
child: Text('Correction distorsion:', style: TextStyle(color: Colors.white)),
|
||||
child: Text(
|
||||
'Correction distorsion:',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
if (provider.distortionParams == null)
|
||||
ElevatedButton.icon(
|
||||
@@ -333,7 +462,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.blueGrey,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 4,
|
||||
),
|
||||
),
|
||||
)
|
||||
else ...[
|
||||
@@ -347,28 +479,43 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 4,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.check_circle, color: Colors.green, size: 16),
|
||||
const Icon(
|
||||
Icons.check_circle,
|
||||
color: Colors.green,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Text('Corrigée', style: TextStyle(color: Colors.green, fontSize: 12)),
|
||||
const Text(
|
||||
'Corrigée',
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Switch(
|
||||
/*Switch(
|
||||
value: provider.distortionCorrectionEnabled,
|
||||
onChanged: (value) => provider.setDistortionCorrectionEnabled(value),
|
||||
activeTrackColor: AppTheme.primaryColor.withValues(alpha: 0.5),
|
||||
onChanged: (value) => provider
|
||||
.setDistortionCorrectionEnabled(value),
|
||||
activeTrackColor: AppTheme.primaryColor
|
||||
.withValues(alpha: 0.5),
|
||||
activeThumbColor: AppTheme.primaryColor,
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -391,8 +538,21 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
initialRingCount: provider.ringCount,
|
||||
initialRingRadii: provider.ringRadii,
|
||||
targetType: provider.targetType!,
|
||||
onCalibrationChanged: (centerX, centerY, radius, ringCount, {List<double>? ringRadii}) {
|
||||
provider.adjustTargetPosition(centerX, centerY, radius, ringCount: ringCount, ringRadii: ringRadii);
|
||||
onCalibrationChanged:
|
||||
(
|
||||
centerX,
|
||||
centerY,
|
||||
radius,
|
||||
ringCount, {
|
||||
List<double>? ringRadii,
|
||||
}) {
|
||||
provider.adjustTargetPosition(
|
||||
centerX,
|
||||
centerY,
|
||||
radius,
|
||||
ringCount: ringCount,
|
||||
ringRadii: ringRadii,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -410,10 +570,18 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
Card(
|
||||
color: AppTheme.primaryColor.withValues(alpha: 0.1),
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.tune, color: AppTheme.primaryColor),
|
||||
leading: const Icon(
|
||||
Icons.tune,
|
||||
color: AppTheme.primaryColor,
|
||||
),
|
||||
title: const Text('Calibrer la cible'),
|
||||
subtitle: const Text('Ajustez le centre et la taille'),
|
||||
trailing: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
subtitle: const Text(
|
||||
'Ajustez le centre et la taille',
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 16,
|
||||
),
|
||||
onTap: () => setState(() => _isCalibrating = true),
|
||||
),
|
||||
),
|
||||
@@ -429,7 +597,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Grouping stats
|
||||
if (provider.groupingResult != null && provider.shotCount > 1)
|
||||
if (provider.groupingResult != null &&
|
||||
provider.shotCount > 1)
|
||||
GroupingStats(
|
||||
groupingResult: provider.groupingResult!,
|
||||
targetCenterX: provider.targetCenterX,
|
||||
@@ -446,7 +615,6 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
else
|
||||
// Calibration info
|
||||
Padding(
|
||||
@@ -459,7 +627,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
children: [
|
||||
const Text(
|
||||
'Instructions de calibration',
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInstructionItem(
|
||||
@@ -480,7 +651,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
const Text('Centre: '),
|
||||
Text(
|
||||
'(${(provider.targetCenterX * 100).toStringAsFixed(1)}%, ${(provider.targetCenterY * 100).toStringAsFixed(1)}%)',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -489,7 +662,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
const Text('Rayon: '),
|
||||
Text(
|
||||
'${(provider.targetRadius * 100).toStringAsFixed(1)}%',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -506,9 +681,13 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Align(
|
||||
alignment: _isAtBottom ? Alignment.bottomCenter : Alignment.bottomRight,
|
||||
alignment: _isAtBottom
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.bottomRight,
|
||||
child: Padding(
|
||||
padding: _isAtBottom ? EdgeInsets.zero : const EdgeInsets.all(16.0),
|
||||
padding: _isAtBottom
|
||||
? EdgeInsets.zero
|
||||
: const EdgeInsets.all(16.0),
|
||||
child: _isCalibrating
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: () => setState(() => _isCalibrating = false),
|
||||
@@ -519,15 +698,19 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 260),
|
||||
curve: Curves.easeInOut,
|
||||
width: _isAtBottom ? MediaQuery.of(context).size.width : 180,
|
||||
width: _isAtBottom
|
||||
? MediaQuery.of(context).size.width
|
||||
: 180,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.primaryColor,
|
||||
borderRadius: BorderRadius.circular(_isAtBottom ? 0 : 16),
|
||||
borderRadius: BorderRadius.circular(
|
||||
_isAtBottom ? 0 : 16,
|
||||
),
|
||||
boxShadow: [
|
||||
if (!_isAtBottom)
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
color: Colors.black.withValues(alpha: 0.2),
|
||||
blurRadius: 6,
|
||||
offset: const Offset(0, 3),
|
||||
),
|
||||
@@ -537,9 +720,14 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => _saveSession(context, provider),
|
||||
borderRadius: BorderRadius.circular(_isAtBottom ? 0 : 16),
|
||||
borderRadius: BorderRadius.circular(
|
||||
_isAtBottom ? 0 : 16,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 16,
|
||||
),
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Row(
|
||||
@@ -549,11 +737,13 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
const Icon(Icons.save, color: Colors.white),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
_isAtBottom ? 'SAUVEGARDER LA SESSION' : 'Sauvegarder',
|
||||
_isAtBottom
|
||||
? 'SAUVEGARDER LA SESSION'
|
||||
: 'Sauvegarder',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -570,7 +760,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildZoomableImageWithOverlay(BuildContext context, AnalysisProvider provider) {
|
||||
Widget _buildZoomableImageWithOverlay(
|
||||
BuildContext context,
|
||||
AnalysisProvider provider,
|
||||
) {
|
||||
return ClipRect(
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
@@ -616,11 +809,25 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
groupingCenterX: provider.groupingResult?.centerX,
|
||||
groupingCenterY: provider.groupingResult?.centerY,
|
||||
groupingDiameter: provider.groupingResult?.diameter,
|
||||
referenceImpacts: _isSelectingReferences ? provider.referenceImpacts : null,
|
||||
referenceImpacts: _isSelectingReferences
|
||||
? provider.referenceImpacts
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Bouton pour effacer les impacts
|
||||
if (provider.shotCount > 0 && !_isSelectingReferences)
|
||||
Positioned(
|
||||
left: 8,
|
||||
bottom: 8,
|
||||
child: FloatingActionButton.small(
|
||||
heroTag: 'clearShots',
|
||||
onPressed: () => _showClearConfirmation(context, provider),
|
||||
backgroundColor: Colors.black54,
|
||||
child: const Icon(Icons.delete, color: Colors.white),
|
||||
),
|
||||
),
|
||||
// Bouton pour passer en mode plein écran d'édition
|
||||
Positioned(
|
||||
right: 8,
|
||||
@@ -637,7 +844,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFullscreenEditContent(BuildContext context, AnalysisProvider provider) {
|
||||
Widget _buildFullscreenEditContent(
|
||||
BuildContext context,
|
||||
AnalysisProvider provider,
|
||||
) {
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
@@ -672,7 +882,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
ringCount: provider.ringCount,
|
||||
ringRadii: provider.ringRadii,
|
||||
zoomScale: _currentZoomScale,
|
||||
onShotTapped: (shot) => _showShotOptions(context, provider, shot.id),
|
||||
onShotTapped: (shot) =>
|
||||
_showShotOptions(context, provider, shot.id),
|
||||
onAddShot: (x, y) {
|
||||
provider.addShot(x, y);
|
||||
},
|
||||
@@ -702,12 +913,17 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Mode édition - Touchez pour ajouter des impacts',
|
||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${provider.shotCount} impacts',
|
||||
style: TextStyle(color: Colors.white.withValues(alpha: 0.8)),
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.8),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -813,7 +1029,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: provider.referenceImpacts.length >= 2
|
||||
? () => _showCalibratedDetectionDialog(context, provider)
|
||||
? () => _showCalibratedDetectionDialog(
|
||||
context,
|
||||
provider,
|
||||
)
|
||||
: null,
|
||||
icon: const Icon(Icons.auto_fix_high),
|
||||
label: const Text('Detecter'),
|
||||
@@ -864,28 +1083,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
// ),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
|
||||
// Manual actions
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: _isSelectingReferences ? null : () => _showAddShotHint(context),
|
||||
icon: const Icon(Icons.add_circle_outline),
|
||||
label: const Text('Ajouter'),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: provider.shotCount > 0 && !_isSelectingReferences
|
||||
? () => _showClearConfirmation(context, provider)
|
||||
: null,
|
||||
icon: const Icon(Icons.clear_all),
|
||||
label: const Text('Effacer'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -899,7 +1098,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('1. Calibrez d\'abord la cible en utilisant le bouton de calibration'),
|
||||
Text(
|
||||
'1. Calibrez d\'abord la cible en utilisant le bouton de calibration',
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Text('2. Appuyez sur l\'image pour ajouter un impact manuellement'),
|
||||
SizedBox(height: 8),
|
||||
@@ -918,7 +1119,11 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
);
|
||||
}
|
||||
|
||||
void _showShotOptions(BuildContext context, AnalysisProvider provider, String shotId) {
|
||||
void _showShotOptions(
|
||||
BuildContext context,
|
||||
AnalysisProvider provider,
|
||||
String shotId,
|
||||
) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => SafeArea(
|
||||
@@ -938,6 +1143,7 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
void _showAddShotHint(BuildContext context) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
@@ -946,6 +1152,7 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
),
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
void _showClearConfirmation(BuildContext context, AnalysisProvider provider) {
|
||||
showDialog(
|
||||
@@ -965,13 +1172,17 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('Effacer', style: TextStyle(color: AppTheme.errorColor)),
|
||||
child: const Text(
|
||||
'Effacer',
|
||||
style: TextStyle(color: AppTheme.errorColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
void _showAutoDetectDialog(BuildContext context, AnalysisProvider provider) {
|
||||
// Detection settings
|
||||
bool clearExisting = true;
|
||||
@@ -1025,7 +1236,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Circularity slider
|
||||
Text('Circularite minimum: ${(minCircularity * 100).toStringAsFixed(0)}%'),
|
||||
Text(
|
||||
'Circularite minimum: ${(minCircularity * 100).toStringAsFixed(0)}%',
|
||||
),
|
||||
Slider(
|
||||
value: minCircularity,
|
||||
min: 0.3,
|
||||
@@ -1043,7 +1256,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Fill ratio slider
|
||||
Text('Remplissage minimum: ${(minFillRatio * 100).toStringAsFixed(0)}%'),
|
||||
Text(
|
||||
'Remplissage minimum: ${(minFillRatio * 100).toStringAsFixed(0)}%',
|
||||
),
|
||||
Slider(
|
||||
value: minFillRatio,
|
||||
min: 0.3,
|
||||
@@ -1118,7 +1333,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Text('Detection en cours...'),
|
||||
@@ -1148,7 +1366,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
? '$count impact(s) detecte(s)'
|
||||
: 'Aucun impact detecte. Essayez d\'ajuster les parametres.',
|
||||
),
|
||||
backgroundColor: count > 0 ? AppTheme.successColor : AppTheme.warningColor,
|
||||
backgroundColor: count > 0
|
||||
? AppTheme.successColor
|
||||
: AppTheme.warningColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1161,8 +1381,12 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
),
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
void _showCalibratedDetectionDialog(BuildContext context, AnalysisProvider provider) {
|
||||
void _showCalibratedDetectionDialog(
|
||||
BuildContext context,
|
||||
AnalysisProvider provider,
|
||||
) {
|
||||
double tolerance = 2.0;
|
||||
bool clearExisting = true;
|
||||
// NOTE: OpenCV désactivé - problèmes de build Windows
|
||||
@@ -1190,7 +1414,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.info_outline, color: Colors.deepPurple),
|
||||
const Icon(
|
||||
Icons.info_outline,
|
||||
color: Colors.deepPurple,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
@@ -1262,7 +1489,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Text('Apprentissage des references...'),
|
||||
@@ -1280,7 +1510,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Impossible d\'analyser les references. Essayez de selectionner d\'autres impacts.'),
|
||||
content: Text(
|
||||
'Impossible d\'analyser les references. Essayez de selectionner d\'autres impacts.',
|
||||
),
|
||||
backgroundColor: AppTheme.errorColor,
|
||||
),
|
||||
);
|
||||
@@ -1298,7 +1530,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Text('Detection en cours...'),
|
||||
@@ -1331,7 +1566,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
? '$count impact(s) detecte(s) a partir des references'
|
||||
: 'Aucun impact detecte. Essayez d\'augmenter la tolerance.',
|
||||
),
|
||||
backgroundColor: count > 0 ? AppTheme.successColor : AppTheme.warningColor,
|
||||
backgroundColor: count > 0
|
||||
? AppTheme.successColor
|
||||
: AppTheme.warningColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1354,7 +1591,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _saveSession(BuildContext context, AnalysisProvider provider) async {
|
||||
Future<void> _saveSession(
|
||||
BuildContext context,
|
||||
AnalysisProvider provider,
|
||||
) async {
|
||||
final notesController = TextEditingController();
|
||||
|
||||
final shouldSave = await showDialog<bool>(
|
||||
@@ -1384,7 +1624,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
|
||||
if (shouldSave == true) {
|
||||
try {
|
||||
await provider.saveSession(notes: notesController.text.isEmpty ? null : notesController.text);
|
||||
await provider.saveSession(
|
||||
notes: notesController.text.isEmpty ? null : notesController.text,
|
||||
);
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
library;
|
||||
|
||||
import 'dart:io';
|
||||
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';
|
||||
import '../../core/theme/app_theme.dart';
|
||||
import '../../data/models/target_type.dart';
|
||||
import '../crop/crop_screen.dart';
|
||||
import 'widgets/target_type_selector.dart';
|
||||
import 'widgets/image_source_button.dart';
|
||||
|
||||
class CaptureScreen extends StatefulWidget {
|
||||
@@ -31,24 +31,12 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Nouvelle Analyse'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Nouvelle Analyse')),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(AppConstants.defaultPadding),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// TODO: une fois la cible de silhouette mise en place, rajouter le selecteur
|
||||
// Target type selection
|
||||
// _buildSectionTitle('Type de Cible'),
|
||||
// const SizedBox(height: 12),
|
||||
// TargetTypeSelector(
|
||||
// selectedType: _selectedType,
|
||||
// onTypeSelected: (type) {
|
||||
// setState(() => _selectedType = type);
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: AppConstants.largePadding),
|
||||
|
||||
// Image source selection
|
||||
@@ -59,8 +47,8 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
Expanded(
|
||||
child: ImageSourceButton(
|
||||
icon: Icons.camera_alt,
|
||||
label: 'Camera',
|
||||
onPressed: _isLoading ? null : () => _captureImage(ImageSource.camera),
|
||||
label: 'Scanner',
|
||||
onPressed: _isLoading ? null : _scanDocument,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
@@ -68,7 +56,9 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
child: ImageSourceButton(
|
||||
icon: Icons.photo_library,
|
||||
label: 'Galerie',
|
||||
onPressed: _isLoading ? null : () => _captureImage(ImageSource.gallery),
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: () => _captureImage(ImageSource.gallery),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -87,16 +77,15 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
_buildImagePreview(),
|
||||
|
||||
// Guide text
|
||||
if (_selectedImagePath == null && !_isLoading)
|
||||
_buildGuide(),
|
||||
if (_selectedImagePath == null && !_isLoading) _buildGuide(),
|
||||
],
|
||||
),
|
||||
),
|
||||
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,
|
||||
);
|
||||
@@ -105,9 +94,9 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -160,7 +149,9 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Assurez-vous que la cible est bien centree et visible.',
|
||||
style: TextStyle(color: AppTheme.warningColor.withValues(alpha: 0.8)),
|
||||
style: TextStyle(
|
||||
color: AppTheme.warningColor.withValues(alpha: 0.8),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -175,20 +166,19 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
padding: const EdgeInsets.all(AppConstants.defaultPadding),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.help_outline,
|
||||
size: 48,
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
Icon(Icons.help_outline, size: 48, color: Colors.grey[400]),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'Conseils pour une bonne analyse',
|
||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleSmall?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildGuideItem(Icons.crop_free, 'Cadrez la cible entiere dans l\'image'),
|
||||
_buildGuideItem(
|
||||
Icons.crop_free,
|
||||
'Cadrez la cible entiere dans l\'image',
|
||||
),
|
||||
_buildGuideItem(Icons.wb_sunny, 'Utilisez un bon eclairage'),
|
||||
_buildGuideItem(Icons.straighten, 'Prenez la photo de face'),
|
||||
_buildGuideItem(Icons.blur_off, 'Evitez les images floues'),
|
||||
@@ -211,6 +201,39 @@ class _CaptureScreenState extends State<CaptureScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _scanDocument() async {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
try {
|
||||
final options = DocumentScannerOptions(
|
||||
documentFormat: DocumentFormat.jpeg,
|
||||
mode: ScannerMode.base,
|
||||
pageLimit: 1,
|
||||
isGalleryImport: false,
|
||||
);
|
||||
|
||||
final scanner = DocumentScanner(options: options);
|
||||
final documents = await scanner.scanDocument();
|
||||
|
||||
if (documents.images.isNotEmpty) {
|
||||
setState(() => _selectedImagePath = documents.images.first);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Erreur lors du scan: $e'),
|
||||
backgroundColor: AppTheme.errorColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _captureImage(ImageSource source) async {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
|
||||
@@ -119,7 +119,8 @@ class _CropScreenState extends State<CropScreen> {
|
||||
_viewportSize = Size(constraints.maxWidth, constraints.maxHeight);
|
||||
|
||||
// Taille du carré de crop (90% de la plus petite dimension)
|
||||
_cropSize = math.min(constraints.maxWidth, constraints.maxHeight) * 0.85;
|
||||
_cropSize =
|
||||
math.min(constraints.maxWidth, constraints.maxHeight) * 0.85;
|
||||
|
||||
// Calculer l'échelle initiale si pas encore fait
|
||||
if (_scale == 1.0 && _offset == Offset.zero) {
|
||||
@@ -138,7 +139,7 @@ class _CropScreenState extends State<CropScreen> {
|
||||
child: Transform(
|
||||
transform: Matrix4.identity()
|
||||
..setTranslationRaw(_offset.dx, _offset.dy, 0)
|
||||
..scale(_scale, _scale, 1.0),
|
||||
..scale(_scale, _scale),
|
||||
alignment: Alignment.center,
|
||||
child: Image.file(
|
||||
File(widget.imagePath),
|
||||
@@ -153,10 +154,7 @@ class _CropScreenState extends State<CropScreen> {
|
||||
// Overlay de recadrage
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: CropOverlay(
|
||||
cropSize: _cropSize,
|
||||
showGrid: true,
|
||||
),
|
||||
child: CropOverlay(cropSize: _cropSize, showGrid: true),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -154,7 +154,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
// --- BOUTON SESSIONS (Redirige vers Statistiques) ---
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () => _navigateToStatistics(context),
|
||||
borderRadius: BorderRadius.circular(AppConstants.borderRadius),
|
||||
child: StatsCard(
|
||||
icon: Icons.assessment,
|
||||
title: 'Sessions',
|
||||
@@ -162,7 +166,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
color: AppTheme.primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Ce bouton reste statique (ou tu peux ajouter une action)
|
||||
Expanded(
|
||||
child: StatsCard(
|
||||
icon: Icons.gps_fixed,
|
||||
@@ -176,15 +182,21 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
// --- BOUTON SCORE MOYEN (Redirige vers Historique) ---
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () => _navigateToHistory(context),
|
||||
borderRadius: BorderRadius.circular(AppConstants.borderRadius),
|
||||
child: StatsCard(
|
||||
icon: Icons.trending_up,
|
||||
title: 'Score Moyen',
|
||||
title: 'Historique',
|
||||
value: (_stats!['averageScore'] as double).toStringAsFixed(1),
|
||||
color: AppTheme.warningColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Ce bouton reste statique
|
||||
Expanded(
|
||||
child: StatsCard(
|
||||
icon: Icons.emoji_events,
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
/// écart-type et distribution régionale des tirs.
|
||||
library;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../core/constants/app_constants.dart';
|
||||
@@ -69,22 +68,32 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
}
|
||||
|
||||
void _calculateStats() {
|
||||
debugPrint('Calculating stats for ${_allSessions.length} sessions, period: $_selectedPeriod');
|
||||
debugPrint(
|
||||
'Calculating stats for ${_allSessions.length} sessions, period: $_selectedPeriod',
|
||||
);
|
||||
for (final session in _allSessions) {
|
||||
debugPrint(' Session: ${session.id}, shots: ${session.shots.length}, date: ${session.createdAt}');
|
||||
debugPrint(
|
||||
' Session: ${session.id}, shots: ${session.shots.length}, date: ${session.createdAt}',
|
||||
);
|
||||
}
|
||||
_statistics = _statisticsService.calculateStatistics(
|
||||
_allSessions,
|
||||
period: _selectedPeriod,
|
||||
);
|
||||
debugPrint('Statistics result: totalShots=${_statistics?.totalShots}, totalScore=${_statistics?.totalScore}');
|
||||
debugPrint(
|
||||
'Statistics result: totalShots=${_statistics?.totalShots}, totalScore=${_statistics?.totalScore}',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.singleSession != null ? 'Statistiques Session' : 'Statistiques'),
|
||||
title: Text(
|
||||
widget.singleSession != null
|
||||
? 'Statistiques Session'
|
||||
: 'Statistiques',
|
||||
),
|
||||
),
|
||||
body: _isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
@@ -101,7 +110,11 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.analytics_outlined, size: 64, color: Colors.grey.shade400),
|
||||
Icon(
|
||||
Icons.analytics_outlined,
|
||||
size: 64,
|
||||
color: Colors.grey.shade400,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Aucune donnee disponible',
|
||||
@@ -292,11 +305,17 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: Text('Peu', style: TextStyle(fontSize: 12, color: Colors.grey.shade600)),
|
||||
child: Text(
|
||||
'Peu',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey.shade600),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: Text('Beaucoup', style: TextStyle(fontSize: 12, color: Colors.grey.shade600)),
|
||||
child: Text(
|
||||
'Beaucoup',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey.shade600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -306,28 +325,6 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLegendItem(Color color, String label) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 16,
|
||||
height: 16,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
border: Border.all(color: Colors.grey.shade400),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(label, style: const TextStyle(fontSize: 10)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPrecisionSection() {
|
||||
final precision = _statistics!.precision;
|
||||
|
||||
@@ -339,7 +336,10 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.center_focus_strong, color: AppTheme.successColor),
|
||||
const Icon(
|
||||
Icons.center_focus_strong,
|
||||
color: AppTheme.successColor,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'Precision',
|
||||
@@ -368,12 +368,18 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
],
|
||||
),
|
||||
const Divider(height: 32),
|
||||
_buildStatRow('Distance moyenne du centre',
|
||||
'${(precision.avgDistanceFromCenter * 100).toStringAsFixed(1)}%'),
|
||||
_buildStatRow('Diametre de groupement',
|
||||
'${(precision.groupingDiameter * 100).toStringAsFixed(1)}%'),
|
||||
_buildStatRow('Score moyen',
|
||||
_statistics!.avgScore.toStringAsFixed(2)),
|
||||
_buildStatRow(
|
||||
'Distance moyenne du centre',
|
||||
'${(precision.avgDistanceFromCenter * 100).toStringAsFixed(1)}%',
|
||||
),
|
||||
_buildStatRow(
|
||||
'Diametre de groupement',
|
||||
'${(precision.groupingDiameter * 100).toStringAsFixed(1)}%',
|
||||
),
|
||||
_buildStatRow(
|
||||
'Score moyen',
|
||||
_statistics!.avgScore.toStringAsFixed(2),
|
||||
),
|
||||
_buildStatRow('Meilleur score', '${_statistics!.maxScore}'),
|
||||
_buildStatRow('Plus bas score', '${_statistics!.minScore}'),
|
||||
],
|
||||
@@ -405,7 +411,7 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${value.toStringAsFixed(0)}',
|
||||
value.toStringAsFixed(0),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -415,10 +421,7 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(title, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(fontSize: 10, color: Colors.grey.shade600),
|
||||
@@ -439,7 +442,10 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.stacked_line_chart, color: AppTheme.warningColor),
|
||||
const Icon(
|
||||
Icons.stacked_line_chart,
|
||||
color: AppTheme.warningColor,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'Ecart Type',
|
||||
@@ -453,21 +459,32 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
style: TextStyle(color: Colors.grey.shade600, fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildStatRow('Ecart type X (horizontal)',
|
||||
'${(stdDev.stdDevX * 100).toStringAsFixed(2)}%'),
|
||||
_buildStatRow('Ecart type Y (vertical)',
|
||||
'${(stdDev.stdDevY * 100).toStringAsFixed(2)}%'),
|
||||
_buildStatRow('Ecart type radial',
|
||||
'${(stdDev.stdDevRadial * 100).toStringAsFixed(2)}%'),
|
||||
_buildStatRow('Ecart type score',
|
||||
stdDev.stdDevScore.toStringAsFixed(2)),
|
||||
_buildStatRow(
|
||||
'Ecart type X (horizontal)',
|
||||
'${(stdDev.stdDevX * 100).toStringAsFixed(2)}%',
|
||||
),
|
||||
_buildStatRow(
|
||||
'Ecart type Y (vertical)',
|
||||
'${(stdDev.stdDevY * 100).toStringAsFixed(2)}%',
|
||||
),
|
||||
_buildStatRow(
|
||||
'Ecart type radial',
|
||||
'${(stdDev.stdDevRadial * 100).toStringAsFixed(2)}%',
|
||||
),
|
||||
_buildStatRow(
|
||||
'Ecart type score',
|
||||
stdDev.stdDevScore.toStringAsFixed(2),
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_buildStatRow('Position moyenne X',
|
||||
'${(stdDev.meanX * 100).toStringAsFixed(1)}%'),
|
||||
_buildStatRow('Position moyenne Y',
|
||||
'${(stdDev.meanY * 100).toStringAsFixed(1)}%'),
|
||||
_buildStatRow('Score moyen',
|
||||
stdDev.meanScore.toStringAsFixed(2)),
|
||||
_buildStatRow(
|
||||
'Position moyenne X',
|
||||
'${(stdDev.meanX * 100).toStringAsFixed(1)}%',
|
||||
),
|
||||
_buildStatRow(
|
||||
'Position moyenne Y',
|
||||
'${(stdDev.meanY * 100).toStringAsFixed(1)}%',
|
||||
),
|
||||
_buildStatRow('Score moyen', stdDev.meanScore.toStringAsFixed(2)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -504,7 +521,10 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.compass_calibration, color: AppTheme.primaryColor),
|
||||
const Icon(
|
||||
Icons.compass_calibration,
|
||||
color: AppTheme.primaryColor,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
@@ -536,7 +556,10 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.warning_amber, color: AppTheme.warningColor),
|
||||
const Icon(
|
||||
Icons.warning_amber,
|
||||
color: AppTheme.warningColor,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
@@ -556,7 +579,10 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Sector distribution
|
||||
const Text('Repartition par secteur:', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
const Text(
|
||||
'Repartition par secteur:',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
@@ -572,7 +598,10 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Quadrant distribution
|
||||
const Text('Repartition par quadrant:', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
const Text(
|
||||
'Repartition par quadrant:',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildQuadrantGrid(regional.quadrantDistribution),
|
||||
],
|
||||
@@ -598,7 +627,9 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: count > 0 ? AppTheme.primaryColor.withValues(alpha: 0.1) : Colors.grey.shade100,
|
||||
color: count > 0
|
||||
? AppTheme.primaryColor.withValues(alpha: 0.1)
|
||||
: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: count > 0 ? AppTheme.primaryColor : Colors.grey.shade300,
|
||||
@@ -649,10 +680,7 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
|
||||
children: [
|
||||
Text(
|
||||
'$count',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 24,
|
||||
),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 24),
|
||||
),
|
||||
Text(
|
||||
'${percentage.toStringAsFixed(0)}%',
|
||||
@@ -712,10 +740,7 @@ class _StatCard extends StatelessWidget {
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(color: Colors.grey.shade600),
|
||||
),
|
||||
Text(title, style: TextStyle(color: Colors.grey.shade600)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -8,6 +8,7 @@ library;
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
import 'package:image/image.dart' as img;
|
||||
import 'package:opencv_dart/opencv_dart.dart' as cv;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
/// Paramètres de distorsion calculés à partir de la calibration
|
||||
@@ -281,16 +282,56 @@ class DistortionCorrectionService {
|
||||
final p11 = image.getPixel(x1, y1);
|
||||
|
||||
// Interpoler chaque canal
|
||||
final r = _lerp2D(p00.r.toDouble(), p10.r.toDouble(), p01.r.toDouble(), p11.r.toDouble(), wx, wy);
|
||||
final g = _lerp2D(p00.g.toDouble(), p10.g.toDouble(), p01.g.toDouble(), p11.g.toDouble(), wx, wy);
|
||||
final b = _lerp2D(p00.b.toDouble(), p10.b.toDouble(), p01.b.toDouble(), p11.b.toDouble(), wx, wy);
|
||||
final a = _lerp2D(p00.a.toDouble(), p10.a.toDouble(), p01.a.toDouble(), p11.a.toDouble(), wx, wy);
|
||||
final r = _lerp2D(
|
||||
p00.r.toDouble(),
|
||||
p10.r.toDouble(),
|
||||
p01.r.toDouble(),
|
||||
p11.r.toDouble(),
|
||||
wx,
|
||||
wy,
|
||||
);
|
||||
final g = _lerp2D(
|
||||
p00.g.toDouble(),
|
||||
p10.g.toDouble(),
|
||||
p01.g.toDouble(),
|
||||
p11.g.toDouble(),
|
||||
wx,
|
||||
wy,
|
||||
);
|
||||
final b = _lerp2D(
|
||||
p00.b.toDouble(),
|
||||
p10.b.toDouble(),
|
||||
p01.b.toDouble(),
|
||||
p11.b.toDouble(),
|
||||
wx,
|
||||
wy,
|
||||
);
|
||||
final a = _lerp2D(
|
||||
p00.a.toDouble(),
|
||||
p10.a.toDouble(),
|
||||
p01.a.toDouble(),
|
||||
p11.a.toDouble(),
|
||||
wx,
|
||||
wy,
|
||||
);
|
||||
|
||||
return img.ColorRgba8(r.round().clamp(0, 255), g.round().clamp(0, 255), b.round().clamp(0, 255), a.round().clamp(0, 255));
|
||||
return img.ColorRgba8(
|
||||
r.round().clamp(0, 255),
|
||||
g.round().clamp(0, 255),
|
||||
b.round().clamp(0, 255),
|
||||
a.round().clamp(0, 255),
|
||||
);
|
||||
}
|
||||
|
||||
/// Interpolation linéaire 2D
|
||||
double _lerp2D(double v00, double v10, double v01, double v11, double wx, double wy) {
|
||||
double _lerp2D(
|
||||
double v00,
|
||||
double v10,
|
||||
double v01,
|
||||
double v11,
|
||||
double wx,
|
||||
double wy,
|
||||
) {
|
||||
final top = v00 * (1 - wx) + v10 * wx;
|
||||
final bottom = v01 * (1 - wx) + v11 * wx;
|
||||
return top * (1 - wy) + bottom * wy;
|
||||
@@ -320,7 +361,9 @@ class DistortionCorrectionService {
|
||||
final height = image.height;
|
||||
|
||||
// Convertir les coordonnées normalisées en pixels
|
||||
final srcCorners = corners.map((c) => (x: c.x * width, y: c.y * height)).toList();
|
||||
final srcCorners = corners
|
||||
.map((c) => (x: c.x * width, y: c.y * height))
|
||||
.toList();
|
||||
|
||||
// Calculer la taille du rectangle destination
|
||||
// On prend la moyenne des largeurs et hauteurs
|
||||
@@ -336,20 +379,21 @@ class DistortionCorrectionService {
|
||||
final result = img.Image(width: dstWidth, height: dstHeight);
|
||||
|
||||
// Calculer la matrice de transformation perspective
|
||||
final matrix = _computePerspectiveMatrix(
|
||||
srcCorners,
|
||||
[
|
||||
final matrix = _computePerspectiveMatrix(srcCorners, [
|
||||
(x: 0.0, y: 0.0),
|
||||
(x: dstWidth.toDouble(), y: 0.0),
|
||||
(x: dstWidth.toDouble(), y: dstHeight.toDouble()),
|
||||
(x: 0.0, y: dstHeight.toDouble()),
|
||||
],
|
||||
);
|
||||
]);
|
||||
|
||||
// Appliquer la transformation
|
||||
for (int y = 0; y < dstHeight; y++) {
|
||||
for (int x = 0; x < dstWidth; x++) {
|
||||
final src = _applyPerspectiveTransform(matrix, x.toDouble(), y.toDouble());
|
||||
final src = _applyPerspectiveTransform(
|
||||
matrix,
|
||||
x.toDouble(),
|
||||
y.toDouble(),
|
||||
);
|
||||
|
||||
if (src.x >= 0 && src.x < width && src.y >= 0 && src.y < height) {
|
||||
final pixel = _bilinearInterpolate(image, src.x, src.y);
|
||||
@@ -408,7 +452,10 @@ class DistortionCorrectionService {
|
||||
// Le système 'a' est de taille 8x9 (8 équations, 9 inconnues).
|
||||
// On fixe h8 = 1.0 pour résoudre le système, ce qui nous donne un système 8x8.
|
||||
final int n = 8;
|
||||
final List<List<double>> matrix = List.generate(n, (i) => List<double>.from(a[i]));
|
||||
final List<List<double>> matrix = List.generate(
|
||||
n,
|
||||
(i) => List<double>.from(a[i]),
|
||||
);
|
||||
|
||||
// Vecteur B (les constantes de l'autre côté de l'égalité)
|
||||
// Dans DLT, -h8 * dx (ou dy) devient le terme constant.
|
||||
@@ -462,7 +509,11 @@ class DistortionCorrectionService {
|
||||
return h;
|
||||
}
|
||||
|
||||
({double x, double y}) _applyPerspectiveTransform(List<double> h, double x, double y) {
|
||||
({double x, double y}) _applyPerspectiveTransform(
|
||||
List<double> h,
|
||||
double x,
|
||||
double y,
|
||||
) {
|
||||
final w = h[6] * x + h[7] * y + h[8];
|
||||
if (w.abs() < 1e-10) {
|
||||
return (x: x, y: y);
|
||||
@@ -471,4 +522,158 @@ class DistortionCorrectionService {
|
||||
final ny = (h[3] * x + h[4] * y + h[5]) / w;
|
||||
return (x: nx, y: ny);
|
||||
}
|
||||
|
||||
/// Corrige la perspective en se basant sur la détection de cercles (ellipses)
|
||||
/// dans l'image.
|
||||
///
|
||||
/// Cette méthode tente de détecter l'ellipse la plus proéminente (la cible)
|
||||
/// et calcule une transformation pour la rendre parfaitement circulaire.
|
||||
Future<String> correctPerspectiveUsingCircles(String imagePath) async {
|
||||
try {
|
||||
// 1. Charger l'image avec OpenCV
|
||||
final src = cv.imread(imagePath, flags: cv.IMREAD_COLOR);
|
||||
if (src.isEmpty) throw Exception("Impossible de charger l'image");
|
||||
|
||||
// 2. Prétraitement
|
||||
final gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY);
|
||||
final blurred = cv.gaussianBlur(gray, (5, 5), 0);
|
||||
|
||||
// Canny edge detector avec seuil adaptatif (Otsu)
|
||||
final thresh = cv.threshold(
|
||||
blurred,
|
||||
0,
|
||||
255,
|
||||
cv.THRESH_BINARY | cv.THRESH_OTSU,
|
||||
);
|
||||
final edges = cv.canny(blurred, thresh.$1 * 0.5, thresh.$1);
|
||||
|
||||
// 3. Trouver les contours
|
||||
final contoursResult = cv.findContours(
|
||||
edges,
|
||||
cv.RETR_EXTERNAL,
|
||||
cv.CHAIN_APPROX_SIMPLE,
|
||||
);
|
||||
final contours = contoursResult.$1;
|
||||
|
||||
if (contours.isEmpty) return imagePath; // Pas de contours trouvés
|
||||
|
||||
// 4. Trouver le meilleur candidat ellipse
|
||||
cv.RotatedRect? bestEllipse;
|
||||
double maxArea = 0;
|
||||
|
||||
for (final contour in contours) {
|
||||
if (contour.length < 5)
|
||||
continue; // fitEllipse nécessite au moins 5 points
|
||||
|
||||
final area = cv.contourArea(contour);
|
||||
if (area < 1000) continue; // Ignorer les trop petits bruits
|
||||
|
||||
final ellipse = cv.fitEllipse(contour);
|
||||
|
||||
// Critère de sélection: on cherche la plus grande ellipse qui est proche d'un cercle
|
||||
// Mais comme on veut corriger la distorsion, elle PEUT être aplatie.
|
||||
// Donc on prend juste la plus grande ellipse raisonnablement centrée.
|
||||
if (area > maxArea) {
|
||||
maxArea = area;
|
||||
bestEllipse = ellipse;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestEllipse == null) return imagePath;
|
||||
|
||||
// 5. Calculer la transformation perspective
|
||||
// L'idée est de mapper les 4 sommets de l'ellipse détectée vers un cercle parfait.
|
||||
// Ou plus simplement, mapper le rectangle englobant de l'ellipse vers un carré.
|
||||
|
||||
// Points source: les 4 coins du rotated rect de l'ellipse
|
||||
// Note: opencv_dart RotatedRect points() non dispo directement?
|
||||
// On peut utiliser boxPoints(ellipse)
|
||||
final boxPoints = cv.boxPoints(bestEllipse);
|
||||
// boxPoints returns Mat (4x2 float32)
|
||||
|
||||
// Extraire les 4 points
|
||||
final List<cv.Point> srcPoints = [];
|
||||
|
||||
for (int i = 0; i < boxPoints.length; i++) {
|
||||
// On accède directement au point à l'index i
|
||||
final point2f = boxPoints[i];
|
||||
|
||||
// On convertit les coordonnées float en int pour cv.Point
|
||||
srcPoints.add(cv.Point(point2f.x.toInt(), point2f.y.toInt()));
|
||||
}
|
||||
|
||||
// Trier les points pour avoir: TL, TR, BR, BL
|
||||
_sortPoints(srcPoints);
|
||||
|
||||
// Dimensions cibles
|
||||
final side = math
|
||||
.max(bestEllipse.size.width, bestEllipse.size.height)
|
||||
.toInt();
|
||||
|
||||
final List<cv.Point> dstPoints = [
|
||||
cv.Point(0, 0),
|
||||
cv.Point(side, 0),
|
||||
cv.Point(side, side),
|
||||
cv.Point(0, side),
|
||||
];
|
||||
|
||||
// Matrice de perspective
|
||||
final M = cv.getPerspectiveTransform(
|
||||
cv.VecPoint.fromList(srcPoints),
|
||||
cv.VecPoint.fromList(dstPoints),
|
||||
);
|
||||
|
||||
// 6. Warper l'image
|
||||
final corrected = cv.warpPerspective(src, M, (side, side));
|
||||
|
||||
// 7. Sauvegarder
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final outputPath = '${tempDir.path}/corrected_circle_$timestamp.jpg';
|
||||
|
||||
cv.imwrite(outputPath, corrected);
|
||||
|
||||
return outputPath;
|
||||
} catch (e) {
|
||||
// En cas d'erreur, retourner l'image originale
|
||||
print('Erreur correction perspective cercles: $e');
|
||||
return imagePath;
|
||||
}
|
||||
}
|
||||
|
||||
/// Trie les points dans l'ordre: Top-Left, Top-Right, Bottom-Right, Bottom-Left
|
||||
void _sortPoints(List<cv.Point> points) {
|
||||
// Calculer le centre de gravité
|
||||
double cx = 0;
|
||||
double cy = 0;
|
||||
for (final p in points) {
|
||||
cx += p.x;
|
||||
cy += p.y;
|
||||
}
|
||||
cx /= points.length;
|
||||
cy /= points.length;
|
||||
|
||||
points.sort((a, b) {
|
||||
// Trier par angle autour du centre
|
||||
final angleA = math.atan2(a.y - cy, a.x - cx);
|
||||
final angleB = math.atan2(b.y - cy, b.x - cx);
|
||||
return angleA.compareTo(angleB);
|
||||
});
|
||||
|
||||
// Re-trier pour être sûr:
|
||||
points.sort((a, b) => (a.y + a.x).compareTo(b.y + b.x));
|
||||
final tl = points[0];
|
||||
final br = points[3];
|
||||
|
||||
// Reste tr et bl
|
||||
final remaining = [points[1], points[2]];
|
||||
remaining.sort((a, b) => a.x.compareTo(b.x));
|
||||
final bl = remaining[0];
|
||||
final tr = remaining[1];
|
||||
|
||||
points[0] = tl;
|
||||
points[1] = tr;
|
||||
points[2] = br;
|
||||
points[3] = bl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
/// Service de détection d'impacts utilisant OpenCV.
|
||||
///
|
||||
/// NOTE: OpenCV est actuellement désactivé sur Windows en raison de problèmes
|
||||
/// de compilation. Ce fichier contient des stubs qui permettent au code de
|
||||
/// compiler sans OpenCV. Réactiver opencv_dart dans pubspec.yaml et
|
||||
/// décommenter le code ci-dessous quand le support sera corrigé.
|
||||
library;
|
||||
|
||||
// import 'dart:math' as math;
|
||||
// import 'package:opencv_dart/opencv_dart.dart' as cv;
|
||||
import 'dart:math' as math;
|
||||
import 'package:opencv_dart/opencv_dart.dart' as cv;
|
||||
|
||||
/// Paramètres de détection d'impacts OpenCV
|
||||
class OpenCVDetectionSettings {
|
||||
@@ -90,30 +85,144 @@ class OpenCVDetectedImpact {
|
||||
}
|
||||
|
||||
/// Service de détection d'impacts utilisant OpenCV
|
||||
///
|
||||
/// NOTE: Actuellement désactivé - retourne des listes vides.
|
||||
/// OpenCV n'est pas disponible sur Windows pour le moment.
|
||||
class OpenCVImpactDetectionService {
|
||||
/// Détecte les impacts dans une image en utilisant OpenCV
|
||||
///
|
||||
/// STUB: Retourne une liste vide car OpenCV est désactivé.
|
||||
List<OpenCVDetectedImpact> detectImpacts(
|
||||
String imagePath, {
|
||||
OpenCVDetectionSettings settings = const OpenCVDetectionSettings(),
|
||||
}) {
|
||||
print('OpenCV est désactivé - utilisation de la détection classique recommandée');
|
||||
try {
|
||||
final img = cv.imread(imagePath, flags: cv.IMREAD_COLOR);
|
||||
if (img.isEmpty) return [];
|
||||
|
||||
final gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY);
|
||||
|
||||
// Apply blur to reduce noise
|
||||
final blurKSize = (settings.blurSize, settings.blurSize);
|
||||
final blurred = cv.gaussianBlur(gray, blurKSize, 2, sigmaY: 2);
|
||||
|
||||
final List<OpenCVDetectedImpact> detectedImpacts = [];
|
||||
|
||||
final circles = cv.HoughCircles(
|
||||
blurred,
|
||||
cv.HOUGH_GRADIENT,
|
||||
1,
|
||||
settings.minDist,
|
||||
param1: settings.param1,
|
||||
param2: settings.param2,
|
||||
minRadius: settings.minRadius,
|
||||
maxRadius: settings.maxRadius,
|
||||
);
|
||||
|
||||
if (circles.rows > 0 && circles.cols > 0) {
|
||||
// Mat shape: (1, N, 3) usually for HoughCircles (CV_32FC3)
|
||||
// We use at<Vec3f> directly.
|
||||
|
||||
for (int i = 0; i < circles.cols; i++) {
|
||||
final vec = circles.at<cv.Vec3f>(0, i);
|
||||
final x = vec.val1;
|
||||
final y = vec.val2;
|
||||
final r = vec.val3;
|
||||
|
||||
detectedImpacts.add(
|
||||
OpenCVDetectedImpact(
|
||||
x: x / img.cols,
|
||||
y: y / img.rows,
|
||||
radius: r,
|
||||
confidence: 0.8,
|
||||
method: 'hough',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Contour Detection (if enabled)
|
||||
if (settings.useContourDetection) {
|
||||
// Canny edge detection
|
||||
final edges = cv.canny(
|
||||
blurred,
|
||||
settings.cannyThreshold1,
|
||||
settings.cannyThreshold2,
|
||||
);
|
||||
|
||||
// Find contours
|
||||
final contoursResult = cv.findContours(
|
||||
edges,
|
||||
cv.RETR_EXTERNAL,
|
||||
cv.CHAIN_APPROX_SIMPLE,
|
||||
);
|
||||
|
||||
final contours = contoursResult.$1;
|
||||
// hierarchy is item2
|
||||
|
||||
for (int i = 0; i < contours.length; i++) {
|
||||
final contour = contours[i];
|
||||
|
||||
// Filter by area
|
||||
final area = cv.contourArea(contour);
|
||||
if (area < settings.minContourArea ||
|
||||
area > settings.maxContourArea) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filter by circularity
|
||||
final perimeter = cv.arcLength(contour, true);
|
||||
if (perimeter == 0) continue;
|
||||
final circularity = 4 * math.pi * area / (perimeter * perimeter);
|
||||
|
||||
if (circularity < settings.minCircularity) continue;
|
||||
|
||||
// Get bounding circle
|
||||
final enclosingCircle = cv.minEnclosingCircle(contour);
|
||||
final center = enclosingCircle.$1;
|
||||
final radius = enclosingCircle.$2;
|
||||
|
||||
// Avoid duplicates (simple distance check against Hough results)
|
||||
bool isDuplicate = false;
|
||||
for (final existing in detectedImpacts) {
|
||||
final dx = existing.x * img.cols - center.x;
|
||||
final dy = existing.y * img.rows - center.y;
|
||||
final dist = math.sqrt(dx * dx + dy * dy);
|
||||
if (dist < radius) {
|
||||
isDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isDuplicate) {
|
||||
detectedImpacts.add(
|
||||
OpenCVDetectedImpact(
|
||||
x: center.x / img.cols,
|
||||
y: center.y / img.rows,
|
||||
radius: radius,
|
||||
confidence: circularity, // Use circularity as confidence
|
||||
method: 'contour',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return detectedImpacts;
|
||||
} catch (e) {
|
||||
// print('OpenCV Error: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/// Détecte les impacts en utilisant une image de référence
|
||||
///
|
||||
/// STUB: Retourne une liste vide car OpenCV est désactivé.
|
||||
List<OpenCVDetectedImpact> detectFromReferences(
|
||||
String imagePath,
|
||||
List<({double x, double y})> referencePoints, {
|
||||
double tolerance = 2.0,
|
||||
}) {
|
||||
print('OpenCV est désactivé - utilisation de la détection par références classique recommandée');
|
||||
return [];
|
||||
// Basic implementation: use average color/brightness of reference points
|
||||
// This is a placeholder for a more complex template matching or feature matching
|
||||
|
||||
// For now, we can just run the standard detection but filter results
|
||||
// based on properties of the reference points (e.g. size/radius if we had it).
|
||||
|
||||
// Returning standard detection for now to enable the feature.
|
||||
return detectImpacts(imagePath);
|
||||
}
|
||||
}
|
||||
|
||||
235
lib/services/opencv_target_service.dart
Normal file
235
lib/services/opencv_target_service.dart
Normal file
@@ -0,0 +1,235 @@
|
||||
import 'dart:math' as math;
|
||||
import 'package:opencv_dart/opencv_dart.dart' as cv;
|
||||
|
||||
class TargetDetectionResult {
|
||||
final double centerX;
|
||||
final double centerY;
|
||||
final double radius;
|
||||
final bool success;
|
||||
|
||||
TargetDetectionResult({
|
||||
required this.centerX,
|
||||
required this.centerY,
|
||||
required this.radius,
|
||||
this.success = true,
|
||||
});
|
||||
|
||||
factory TargetDetectionResult.failure() {
|
||||
return TargetDetectionResult(
|
||||
centerX: 0.5,
|
||||
centerY: 0.5,
|
||||
radius: 0.4,
|
||||
success: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class OpenCVTargetService {
|
||||
/// Detect the main target (center and radius) from an image file
|
||||
Future<TargetDetectionResult> detectTarget(String imagePath) async {
|
||||
try {
|
||||
// Read image
|
||||
final img = cv.imread(imagePath, flags: cv.IMREAD_COLOR);
|
||||
if (img.isEmpty) {
|
||||
return TargetDetectionResult.failure();
|
||||
}
|
||||
|
||||
// Convert to grayscale
|
||||
final gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY);
|
||||
|
||||
// Apply Gaussian blur to reduce noise
|
||||
final blurred = cv.gaussianBlur(gray, (9, 9), 2, sigmaY: 2);
|
||||
|
||||
// Detect circles using Hough Transform
|
||||
// Parameters need to be tuned for the specific target type
|
||||
final circles = cv.HoughCircles(
|
||||
blurred,
|
||||
cv.HOUGH_GRADIENT,
|
||||
1, // dp: Inverse ratio of the accumulator resolution to the image resolution
|
||||
(img.rows / 8)
|
||||
.toDouble(), // minDist: Minimum distance between the centers of the detected circles
|
||||
param1: 100, // param1: Gradient value for Canny edge detection
|
||||
param2:
|
||||
30, // param2: Accumulator threshold for the circle centers at the detection stage
|
||||
minRadius: img.cols ~/ 20, // minRadius
|
||||
maxRadius: img.cols ~/ 2, // maxRadius
|
||||
);
|
||||
|
||||
// HoughCircles returns a Mat of shape (1, N, 3) where N is number of circles.
|
||||
// In opencv_dart, we cannot iterate easily.
|
||||
// However, we can access data via pointer if needed, or check if Vec3f is supported.
|
||||
// Given the user report, `at<Vec3f>` likely failed compilation or runtime.
|
||||
// Let's use a safer approach: assume standard memory layout (x, y, r, x, y, r...).
|
||||
// Or use `at<double>` carefully.
|
||||
|
||||
// Better yet: try to use `circles.data` if available, but it returns a Pointer.
|
||||
// Let's stick to `at` but use `double` and manual offset if Vec3f fails.
|
||||
// actually, let's try to trust `at<double>` for flattened access OR `at<Vec3f>`.
|
||||
// NOTE: `at<Vec3f>` was reported as "method at not defined for VecPoint2f" earlier, NOT for Mat.
|
||||
// The user error was for `VecPoint2f`. `Mat` definitely has `at`.
|
||||
// BUT `VecPoint2f` is a List-like structure in Dart wrapper.
|
||||
// usage of `at` on `VecPoint2f` was the error.
|
||||
// Here `circles` IS A MAT. So `at` IS defined.
|
||||
// However, to be safe and robust, and to implement clustering...
|
||||
|
||||
if (circles.isEmpty) {
|
||||
// Try with different parameters if first attempt fails (more lenient)
|
||||
final looseCircles = cv.HoughCircles(
|
||||
blurred,
|
||||
cv.HOUGH_GRADIENT,
|
||||
1,
|
||||
(img.rows / 8).toDouble(),
|
||||
param1: 50,
|
||||
param2: 20,
|
||||
minRadius: img.cols ~/ 20,
|
||||
maxRadius: img.cols ~/ 2,
|
||||
);
|
||||
|
||||
if (looseCircles.isEmpty) {
|
||||
return TargetDetectionResult.failure();
|
||||
}
|
||||
return _findBestConcentricCircles(looseCircles, img.cols, img.rows);
|
||||
}
|
||||
|
||||
return _findBestConcentricCircles(circles, img.cols, img.rows);
|
||||
} catch (e) {
|
||||
// print('Error detecting target with OpenCV: $e');
|
||||
return TargetDetectionResult.failure();
|
||||
}
|
||||
}
|
||||
|
||||
TargetDetectionResult _findBestConcentricCircles(
|
||||
cv.Mat circles,
|
||||
int width,
|
||||
int height,
|
||||
) {
|
||||
if (circles.rows == 0 || circles.cols == 0) {
|
||||
return TargetDetectionResult.failure();
|
||||
}
|
||||
|
||||
final int numCircles = circles.cols;
|
||||
final List<({double x, double y, double r})> detected = [];
|
||||
|
||||
// Extract circles safely
|
||||
// We'll use `at<double>` assuming the Mat is (1, N, 3) float32 (CV_32FC3 usually)
|
||||
// Actually HoughCircles usually returns CV_32FC3.
|
||||
// So we can access `at<cv.Vec3f>(0, i)`.
|
||||
// If that fails, we can fall back. But since `Mat` has `at`, it should work unless generic is bad.
|
||||
// Let's assume it works for Mat but checking boundaries.
|
||||
|
||||
// NOTE: If this throws "at not defined" (unlikely for Mat), we'd need another way.
|
||||
// But since the previous error was on `VecPoint2f` (which is NOT a Mat), this should be fine.
|
||||
|
||||
for (int i = 0; i < numCircles; i++) {
|
||||
// Access using Vec3f if possible, or try to interpret memory
|
||||
// Using `at<cv.Vec3f>` is the standard way.
|
||||
final vec = circles.at<cv.Vec3f>(0, i);
|
||||
detected.add((x: vec.val1, y: vec.val2, r: vec.val3));
|
||||
}
|
||||
|
||||
if (detected.isEmpty) return TargetDetectionResult.failure();
|
||||
|
||||
// Cluster circles by center position
|
||||
// We consider circles "concentric" if their centers are within 5% of image min dimension
|
||||
final double tolerance = math.min(width, height) * 0.05;
|
||||
final List<List<({double x, double y, double r})>> clusters = [];
|
||||
|
||||
for (final circle in detected) {
|
||||
bool added = false;
|
||||
for (final cluster in clusters) {
|
||||
// Check distance to cluster center (average of existing)
|
||||
double clusterX = 0;
|
||||
double clusterY = 0;
|
||||
for (final c in cluster) {
|
||||
clusterX += c.x;
|
||||
clusterY += c.y;
|
||||
}
|
||||
clusterX /= cluster.length;
|
||||
clusterY /= cluster.length;
|
||||
|
||||
final dist = math.sqrt(
|
||||
math.pow(circle.x - clusterX, 2) + math.pow(circle.y - clusterY, 2),
|
||||
);
|
||||
|
||||
if (dist < tolerance) {
|
||||
cluster.add(circle);
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!added) {
|
||||
clusters.add([circle]);
|
||||
}
|
||||
}
|
||||
|
||||
// Find the best cluster
|
||||
// 1. Prefer clusters with more circles (concentric rings)
|
||||
// 2. Tie-break: closest to image center
|
||||
|
||||
List<({double x, double y, double r})> bestCluster = clusters.first;
|
||||
double bestScore = -1.0;
|
||||
|
||||
for (final cluster in clusters) {
|
||||
// Score calculation
|
||||
// Base score = number of circles * 10
|
||||
double score = cluster.length * 10.0;
|
||||
|
||||
// Penalize distance from center
|
||||
double cx = 0, cy = 0;
|
||||
for (final c in cluster) {
|
||||
cx += c.x;
|
||||
cy += c.y;
|
||||
}
|
||||
cx /= cluster.length;
|
||||
cy /= cluster.length;
|
||||
|
||||
final distFromCenter = math.sqrt(
|
||||
math.pow(cx - width / 2, 2) + math.pow(cy - height / 2, 2),
|
||||
);
|
||||
final relDist = distFromCenter / math.min(width, height);
|
||||
|
||||
score -= relDist * 5.0; // Moderate penalty for off-center
|
||||
|
||||
// Penalize very small clusters if they are just noise
|
||||
// (Optional: check if radii are somewhat distributed?)
|
||||
|
||||
if (score > bestScore) {
|
||||
bestScore = score;
|
||||
bestCluster = cluster;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute final result from best cluster
|
||||
// Center: Use the smallest circle (bullseye) for best precision
|
||||
// Radius: Use the largest circle (outer edge) for full coverage
|
||||
|
||||
double centerX = 0;
|
||||
double centerY = 0;
|
||||
double maxR = 0;
|
||||
double minR = double.infinity;
|
||||
|
||||
for (final c in bestCluster) {
|
||||
if (c.r > maxR) {
|
||||
maxR = c.r;
|
||||
}
|
||||
if (c.r < minR) {
|
||||
minR = c.r;
|
||||
centerX = c.x;
|
||||
centerY = c.y;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback if something went wrong (shouldn't happen with non-empty cluster)
|
||||
if (minR == double.infinity) {
|
||||
centerX = bestCluster.first.x;
|
||||
centerY = bestCluster.first.y;
|
||||
}
|
||||
|
||||
return TargetDetectionResult(
|
||||
centerX: centerX / width,
|
||||
centerY: centerY / height,
|
||||
radius: maxR / math.min(width, height),
|
||||
success: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
54
pubspec.lock
54
pubspec.lock
@@ -25,6 +25,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
change_case:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: change_case
|
||||
sha256: e41ef3df58521194ef8d7649928954805aeb08061917cf658322305e61568003
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -61,10 +69,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cross_file
|
||||
sha256: "701dcfc06da0882883a2657c445103380e53e647060ad8d9dfb710c100996608"
|
||||
sha256: "28bb3ae56f117b5aec029d702a90f57d285cd975c3c5c281eaca38dbc47c5937"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.5+1"
|
||||
version: "0.3.5+2"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -81,6 +89,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.8"
|
||||
dartcv4:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dartcv4
|
||||
sha256: "43dba49162662f3b6e3daf5a95d071429365e2f1ada67d412b851fc9be442e58"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1+1"
|
||||
equatable:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -200,6 +216,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
google_mlkit_document_scanner:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_mlkit_document_scanner
|
||||
sha256: "67428ddb853880c8185049a5834cd328e6420921a74786f6aadee0b76f8536bd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
hooks:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -244,10 +268,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_android
|
||||
sha256: "5e9bf126c37c117cf8094215373c6d561117a3cfb50ebc5add1a61dc6e224677"
|
||||
sha256: "518a16108529fc18657a3e6dde4a043dc465d16596d20ab2abd49a4cac2e703d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.13+10"
|
||||
version: "0.8.13+13"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -260,10 +284,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_ios
|
||||
sha256: "956c16a42c0c708f914021666ffcd8265dde36e673c9fa68c81f7d085d9774ad"
|
||||
sha256: b9c4a438a9ff4f60808c9cf0039b93a42bb6c2211ef6ebb647394b2b3fa84588
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.13+3"
|
||||
version: "0.8.13+6"
|
||||
image_picker_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -384,6 +408,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.17.4"
|
||||
native_toolchain_cmake:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: native_toolchain_cmake
|
||||
sha256: fe40e8483183ced98e851e08a9cd2a547fd412cccab98277aa23f2377e43d66f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.4"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -392,6 +424,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
opencv_dart:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: opencv_dart
|
||||
sha256: c2b7cc614cad69c2857e9b684e3066af662a03fe7100f4dc9a630e81ad42103a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1+1"
|
||||
path:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -679,4 +719,4 @@ packages:
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.12.0-35.0.dev <4.0.0"
|
||||
flutter: ">=3.35.0"
|
||||
flutter: ">=3.38.1"
|
||||
|
||||
@@ -35,11 +35,11 @@ dependencies:
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.8
|
||||
|
||||
# Image processing with OpenCV (désactivé temporairement - problèmes de build Windows)
|
||||
# opencv_dart: ^2.1.0
|
||||
opencv_dart: ^2.1.0
|
||||
|
||||
# Image capture from camera/gallery
|
||||
image_picker: ^1.0.7
|
||||
image_picker: ^1.2.1
|
||||
google_mlkit_document_scanner: ^0.2.0
|
||||
|
||||
# Local database for history
|
||||
sqflite: ^2.3.2
|
||||
|
||||
Reference in New Issue
Block a user