1
1
import 'package:mobx/mobx.dart' ;
2
2
import 'package:path/path.dart' as path;
3
3
import 'package:pcb_fault_detection_ui/src/data/image_data.dart' ;
4
+ import 'package:pcb_fault_detection_ui/src/data/image_status_tile_data.dart' ;
4
5
import 'package:pcb_fault_detection_ui/src/rust/api/utils.dart' ;
5
6
import 'package:pcb_fault_detection_ui/src/store/project.store.dart' ;
6
7
import 'package:pcb_fault_detection_ui/src/utils/components.dart' ;
@@ -15,7 +16,7 @@ class ImageDataStore extends _ImageDataStore with _$ImageDataStore {
15
16
});
16
17
}
17
18
18
- abstract class _ImageDataStore with Store {
19
+ sealed class _ImageDataStore with Store {
19
20
@observable
20
21
ImageData imageData;
21
22
@@ -54,6 +55,60 @@ abstract class _ImageDataStore with Store {
54
55
return path.join (projectFolder, folderName, IMAGE_FILE_NAME );
55
56
}
56
57
58
+ @computed
59
+ ImageStatusTileData get statusTileData {
60
+ if (imageData.tracksOnly) {
61
+ if (imageData.trackDefects.isEmpty) {
62
+ return ImageStatusTileData (
63
+ status: ImageStatus .Unchecked ,
64
+ statusString: "Please run inference on this image." ,
65
+ );
66
+ }
67
+ final numTrackDefects = imageData.trackDefects
68
+ .where ((v) => v.confidence >= imageData.trackDefectDetectionThreshold)
69
+ .length;
70
+ if (numTrackDefects == 0 ) {
71
+ return ImageStatusTileData (
72
+ status: ImageStatus .Ok ,
73
+ statusString: "No track defects found." ,
74
+ );
75
+ } else {
76
+ return ImageStatusTileData (
77
+ status: ImageStatus .Faulty ,
78
+ statusString: "Track defects: $numTrackDefects " ,
79
+ );
80
+ }
81
+ } else {
82
+ if (imageData.components.isEmpty) {
83
+ return ImageStatusTileData (
84
+ status: ImageStatus .Unchecked ,
85
+ statusString: "Please run inference on this image." ,
86
+ );
87
+ }
88
+ if (parent.benchmarkImageData? .components.isEmpty ?? true ) {
89
+ return ImageStatusTileData (
90
+ status: ImageStatus .Unchecked ,
91
+ statusString: "Please run inference on the benchmark image." ,
92
+ );
93
+ }
94
+ int numMissingComponents =
95
+ nonOverlappingComponents.missingComponents.length;
96
+ int numExtraComponents = nonOverlappingComponents.extraComponents.length;
97
+ if (numMissingComponents == 0 && numExtraComponents == 0 ) {
98
+ return ImageStatusTileData (
99
+ status: ImageStatus .Ok ,
100
+ statusString: "No component defects found." ,
101
+ );
102
+ } else {
103
+ return ImageStatusTileData (
104
+ status: ImageStatus .Faulty ,
105
+ statusString:
106
+ "Missing: $numMissingComponents , Extra: $numExtraComponents " ,
107
+ );
108
+ }
109
+ }
110
+ }
111
+
57
112
@action
58
113
void setComponents (List <YoloEntityOutput > components) {
59
114
imageData = imageData.copyWith (components: components);
0 commit comments