diff --git a/examples/python-operator-dataflow/dataflow.yml b/examples/python-operator-dataflow/dataflow.yml index 92bf5f2b..27d27426 100644 --- a/examples/python-operator-dataflow/dataflow.yml +++ b/examples/python-operator-dataflow/dataflow.yml @@ -14,6 +14,7 @@ nodes: image: webcam/image outputs: - bbox + - logs - id: plot operator: @@ -21,3 +22,4 @@ nodes: inputs: image: webcam/image bbox: object_detection/bbox + object_detection_logs: object_detection/logs diff --git a/examples/python-operator-dataflow/plot.py b/examples/python-operator-dataflow/plot.py index cd7a7200..923ade0e 100755 --- a/examples/python-operator-dataflow/plot.py +++ b/examples/python-operator-dataflow/plot.py @@ -29,6 +29,7 @@ class Operator: self.bboxs = [] self.bounding_box_messages = 0 self.image_messages = 0 + self.object_detection_logs = [] def on_event( self, @@ -69,12 +70,22 @@ class Operator: self.image_messages += 1 print("received " + str(self.image_messages) + " images") + elif dora_input["id"] == "object_detection_logs": + logs = dora_input["value"][0].as_py() + self.object_detection_logs += [logs] + ## Only keep last 10 logs + self.object_detection_logs = self.object_detection_logs[-10:] + return DoraStatus.CONTINUE + elif dora_input["id"] == "bbox" and len(self.image) != 0: bboxs = dora_input["value"].to_numpy() self.bboxs = np.reshape(bboxs, (-1, 6)) self.bounding_box_messages += 1 print("received " + str(self.bounding_box_messages) + " bounding boxes") + return DoraStatus.CONTINUE + else: + return DoraStatus.CONTINUE for bbox in self.bboxs: [ @@ -104,6 +115,18 @@ class Operator: 1, ) + for i, log in enumerate(self.object_detection_logs): + cv2.putText( + self.image, + log, + (10, 10 + 20 * i), + font, + 0.5, + (0, 255, 0), + 2, + 1, + ) + if CI != "true": cv2.imshow("frame", self.image) if cv2.waitKey(1) & 0xFF == ord("q"):