Browse Source

Change Python event types to uppercase

tags/v0.2.0-candidate
Philipp Oppermann 3 years ago
parent
commit
352fb3d757
Failed to extract signature
5 changed files with 13 additions and 13 deletions
  1. +5
    -5
      apis/python/node/src/lib.rs
  2. +2
    -2
      examples/python-dataflow/no_webcam.py
  3. +2
    -2
      examples/python-dataflow/object_detection.py
  4. +2
    -2
      examples/python-dataflow/plot.py
  5. +2
    -2
      examples/python-dataflow/webcam.py

+ 5
- 5
apis/python/node/src/lib.rs View File

@@ -24,7 +24,7 @@ impl IntoPy<PyObject> for PyInput<'_> {
let dict = PyDict::new(py);

let ty = match self.0 {
Event::Stop => "stop",
Event::Stop => "STOP",
Event::Input { id, metadata, data } => {
dict.set_item("id", id.to_string())
.wrap_err("failed to add input ID")
@@ -38,21 +38,21 @@ impl IntoPy<PyObject> for PyInput<'_> {
dict.set_item("metadata", metadata_to_pydict(&metadata, py))
.wrap_err("failed to add input metadata")
.unwrap();
"input"
"INPUT"
}
Event::InputClosed { id } => {
dict.set_item("id", id.to_string())
.wrap_err("failed to add closed-input ID")
.unwrap();
"input-closed"
"INPUT_CLOSED"
}
Event::Error(err) => {
dict.set_item("error", err)
.wrap_err("failed to add error")
.unwrap();
"error"
"ERROR"
}
_other => "unknown",
_other => "UNKNOWN",
};

dict.set_item("type", ty)


+ 2
- 2
examples/python-dataflow/no_webcam.py View File

@@ -19,10 +19,10 @@ while time.time() - start < 20:
# Wait next dora_input
event = node.next()
match event["type"]:
case "input":
case "INPUT":
print("received input", event["id"])
node.send_output("image", arr.tobytes())
case "stop":
case "STOP":
print("received stop")
case other:
print("received unexpected event:", other)


+ 2
- 2
examples/python-dataflow/object_detection.py View File

@@ -15,7 +15,7 @@ node = Node()

for event in node:
match event["type"]:
case "input":
case "INPUT":
match event["id"]:
case "image":
print("received image input")
@@ -28,7 +28,7 @@ for event in node:
node.send_output("bbox", arrays, event["metadata"])
case other:
print("ignoring unexpected input:", other)
case "stop":
case "STOP":
print("received stop")
case other:
print("received unexpected event:", other)

+ 2
- 2
examples/python-dataflow/plot.py View File

@@ -92,7 +92,7 @@ node = Node()

for event in node:
match event["type"]:
case "input":
case "INPUT":
status = plotter.on_input(event)
match status:
case Status.CONTINUE:
@@ -100,7 +100,7 @@ for event in node:
case Status.STOP:
print("plotter returned stop status")
break
case "stop":
case "STOP":
print("received stop")
case other:
print("received unexpected event:", other)

+ 2
- 2
examples/python-dataflow/webcam.py View File

@@ -17,11 +17,11 @@ while time.time() - start < 10:
# Wait next dora_input
event = node.next()
match event["type"]:
case "input":
case "INPUT":
ret, frame = video_capture.read()
if ret:
node.send_output("image", cv2.imencode(".jpg", frame)[1].tobytes())
case "stop":
case "STOP":
print("received stop")
break
case other:


Loading…
Cancel
Save