11import 'package:mobx/mobx.dart' ;
22import 'package:path/path.dart' as path;
33import 'package:pcb_fault_detection_ui/src/data/image_data.dart' ;
4+ import 'package:pcb_fault_detection_ui/src/data/image_status_tile_data.dart' ;
45import 'package:pcb_fault_detection_ui/src/rust/api/utils.dart' ;
56import 'package:pcb_fault_detection_ui/src/store/project.store.dart' ;
67import 'package:pcb_fault_detection_ui/src/utils/components.dart' ;
@@ -15,7 +16,7 @@ class ImageDataStore extends _ImageDataStore with _$ImageDataStore {
1516 });
1617}
1718
18- abstract class _ImageDataStore with Store {
19+ sealed class _ImageDataStore with Store {
1920 @observable
2021 ImageData imageData;
2122
@@ -54,6 +55,60 @@ abstract class _ImageDataStore with Store {
5455 return path.join (projectFolder, folderName, IMAGE_FILE_NAME );
5556 }
5657
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+
57112 @action
58113 void setComponents (List <YoloEntityOutput > components) {
59114 imageData = imageData.copyWith (components: components);
0 commit comments