diff --git a/Auto_Ctrl/predictor_Syringe_Pump.py b/Auto_Ctrl/predictor_Syringe_Pump.py index e2df2c7..2362126 100644 --- a/Auto_Ctrl/predictor_Syringe_Pump.py +++ b/Auto_Ctrl/predictor_Syringe_Pump.py @@ -13,7 +13,7 @@ import json import Find_COM from threading import Thread -LOCAL_DEBUG = True +LOCAL_DEBUG = False if LOCAL_DEBUG: print("WARNING: Local debug mode is enabled. Serial communication will be skipped.") @@ -116,9 +116,10 @@ class MAT: return None ret = self.my_predictor(im) + # print(ret) if ret is None: - cv2.imwrite("tmp.jpg",im) - return self.predictor("tmp.jpg") + print("Failed") + self.thr = Thread(target=self._pred).start() else: if ret == self.end_kind: print("Stop at ",self.total_volume) @@ -129,22 +130,18 @@ class MAT: return ret,0.9 def my_predictor(self,im): - model = self.model - ret = self.preproc(im) - if ret is None: - return None - arr = np.array(ret) - if len(arr.shape) == 1: - arr = arr.reshape(1, -1) - - # 进行预测并转换为类别名 - pred_labels = model.predict(arr) - # pred_classes = [label_map[label] for label in pred_labels] - mp = ["orange", "yellow"] - if len(pred_labels) == 1: - return mp[pred_labels[0]] + # im = cv2.imread(file) + hsv = cv2.cvtColor(im,cv2.COLOR_BGR2HSV) + s = hsv[:,:,1] + mask = s>100 + # print(mask) + tot = mask.shape[0]*mask.shape[1] + val = np.sum(mask) + # print(val/tot) + if val