File size: 2,675 Bytes
2964111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { defineStore } from 'pinia'

export const useCalibrationStore = defineStore('calibration', {
  state: () => ({
    // Flux principal
    mode: null, // 'auto' ou 'manual'
    currentStep: 'mode-selection', // 'mode-selection', 'upload', 'video-type', 'processing', 'results'
    
    // Traitement
    processing: false,
    processingProgress: 0,
    processingTask: '',
    
    // Résultats
    results: null,
    error: null,
    
    // Configuration manuelle
    manualLines: {},
    
    // Configuration vidéo dynamique
    videoProcessingParams: {
      kpThreshold: 0.15,
      lineThreshold: 0.15,
      frameStep: 10
    }
  }),

  getters: {
    isAutoMode: (state) => state.mode === 'auto',
    isManualMode: (state) => state.mode === 'manual',
    hasResults: (state) => state.results !== null,
    isProcessing: (state) => state.processing,
    
    // Étapes actives
    isModeSelection: (state) => state.currentStep === 'mode-selection',
    isUploadStep: (state) => state.currentStep === 'upload',
    isVideoTypeStep: (state) => state.currentStep === 'video-type',
    isProcessingStep: (state) => state.currentStep === 'processing',
    isResultsStep: (state) => state.currentStep === 'results'
  },

  actions: {
    // Navigation entre étapes
    setMode(mode) {
      this.mode = mode
      this.currentStep = 'upload'
    },

    setCurrentStep(step) {
      this.currentStep = step
    },

    // Traitement
    setProcessing(processing, task = '') {
      this.processing = processing
      this.processingTask = task
      if (processing) {
        this.currentStep = 'processing'
      }
    },

    updateProgress(progress, task = '') {
      this.processingProgress = progress
      if (task) this.processingTask = task
    },

    setResults(results) {
      this.results = results
      this.processing = false
      this.error = null
      this.currentStep = 'results'
    },

    setError(error) {
      this.error = error
      this.processing = false
    },

    // Configuration
    setVideoParams(params) {
      this.videoProcessingParams = { ...this.videoProcessingParams, ...params }
    },

    setManualLines(lines) {
      this.manualLines = lines
    },

    // Réinitialisation
    reset() {
      this.mode = null
      this.currentStep = 'mode-selection'
      this.processing = false
      this.processingProgress = 0
      this.processingTask = ''
      this.results = null
      this.error = null
      this.manualLines = {}
    },

    // Passer en mode manuel depuis les résultats
    switchToManual() {
      this.mode = 'manual'
      // On garde les autres données pour permettre le retour
    }
  }
})