diff --git a/simulate.sh b/simulate.sh index 56f8ada..bc9e0e6 100755 --- a/simulate.sh +++ b/simulate.sh @@ -32,6 +32,7 @@ $* 2> >(sed $'s/.*/\e[31m&\e[m/' >&2) # & # --no-gui \ # --no-tflite \ # --sim-archiver \ +# --sim-vision \ # --users-management \ # sudo renice -n -10 $! # fg diff --git a/src/components/tecna_marposs_provaset_t3p.py b/src/components/tecna_marposs_provaset_t3p.py index 2fc3b3c..d612d9e 100644 --- a/src/components/tecna_marposs_provaset_t3p.py +++ b/src/components/tecna_marposs_provaset_t3p.py @@ -165,7 +165,7 @@ class TecnaMarpossProvasetT3P(ModbusComponent): "Test program for read/write operation": table, **{719 - 1 + i: (recipe_name[i * 2 + 1] << 8) + recipe_name[i * 2] for i in range(8)}, "Test type": "Leak Test", - "Test flags": 0b0110000001011000, + "Test flags": 0b0110000001011100, "T0 - Pre-filling time": recipe.spec["pre_filling_time"], "P0 - Pre-filling pressure": recipe.spec["pre_filling_pressure"], "T1 - Filling time": recipe.spec["filling_time"], diff --git a/src/components/vision.py b/src/components/vision.py index 302703f..7bf794f 100644 --- a/src/components/vision.py +++ b/src/components/vision.py @@ -22,7 +22,6 @@ from PyQt5.QtGui import (QBrush, QColor, QFont, QImage, QPainter, QPainterPath, from .component import Component from .consumer import Consumer - if "--no-edgetpu" not in sys.argv: try: from pycoral.utils.edgetpu import make_interpreter @@ -48,7 +47,6 @@ else: def Interpreter(*args, **kwargs): raise ValueError("\"--no-tflite\" in sys.argv") - # # Patch the location of gfile # tf.gfile = tf.io.gfile @@ -293,6 +291,9 @@ class Vision(Component): tf_mode = None # reset tflite variables interpreter = None + if self.simulate: + tf_mode = "simulation" + interpreter = None if tf_mode is None and "edgetpu" in self.allowed_modes: try: # create tflite edgetpu interpreter @@ -334,14 +335,6 @@ class Vision(Component): self.loading_model_signal.emit({"status": "done"}) def check_features(self, frame, lock=True): - # test_box = [i * s for i, s in zip([0.2, 0.2, 0.8, 0.8], frame.shape[:2] * 2)] - # return [{ - # "class": self.category_index[1], - # "score": 1.0, - # "box": test_box, # rescale detection to frame size, - # "center": self.get_center(test_box), - # "size": self.get_size(test_box), - # }] if self.interpreter is not None and frame.shape != self.interpreter.get_input_details()[0]["shape"][1:3]: tensor = np.expand_dims(cv2.resize(frame, self.interpreter.get_input_details()[0]["shape"][1:3], interpolation=cv2.INTER_LINEAR), axis=0) else: @@ -349,7 +342,15 @@ class Vision(Component): # Run inference if lock: self.lock.lock() - if self.tf_mode in {"edgetpu", "tflite"}: + if self.simulate or tf_mode == "simulation": + detections = { + "detection_scores": [[1.0]], + "detection_boxes": [[[0.2, 0.2, 0.8, 0.8]]], + "detection_classes": [[1]], + } + if lock: + self.lock.unlock() + elif self.tf_mode in {"edgetpu", "tflite"}: i_d = self.interpreter.get_input_details() # print(i_d) o_d = self.interpreter.get_output_details() @@ -526,7 +527,7 @@ class Vision(Component): "detection": detection, } return { - "ok": False, # all(map(lambda detection: detection["ok"] is True, checked.values())), + "ok": all(map(lambda detection: detection["ok"] is True, checked.values())), "results": checked, } diff --git a/src/lib/db/__init__.py b/src/lib/db/__init__.py index 6f64acf..f8ef017 100644 --- a/src/lib/db/__init__.py +++ b/src/lib/db/__init__.py @@ -71,14 +71,13 @@ Recipes.replace(id=0, name="TEST", spec={ # filling "filling_time": 5, "settling_time": 10, - "settling_pressure_min_percent": 20, - "settling_pressure_max_percent": 20, + "settling_pressure_min_percent": 10, + "settling_pressure_max_percent": 10, # test - "test_time": 20, + "test_time": 10, "test_pressure_min_delta": 3.00, "test_pressure": 3000, "test_pressure_max_delta": 0.25, - "cycles": 1, # flush "flush_time": 2, "flush_pressure": 5,