You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

plot_node.py 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. """TODO: Add docstring."""
  2. import os
  3. import cv2
  4. from dora import Node
  5. IMAGE_WIDTH = int(os.getenv("IMAGE_WIDTH", "1280"))
  6. IMAGE_HEIGHT = int(os.getenv("IMAGE_HEIGHT", "720"))
  7. FONT = cv2.FONT_HERSHEY_SIMPLEX
  8. node = Node()
  9. joint = None
  10. text = None
  11. for event in node:
  12. if event["type"] == "INPUT":
  13. dora_id = event["id"]
  14. if dora_id == "position":
  15. joint = event["value"].to_numpy()
  16. if "text" in dora_id:
  17. text = event["value"][0].as_py()
  18. if dora_id == "image":
  19. image = (
  20. event["value"].to_numpy().reshape((IMAGE_HEIGHT, IMAGE_WIDTH, 3)).copy()
  21. )
  22. if text is not None:
  23. cv2.putText(
  24. image,
  25. f"Speech: {text}",
  26. (20, 40),
  27. FONT,
  28. 0.5,
  29. (190, 250, 0),
  30. 2,
  31. )
  32. if joint is not None:
  33. cv2.putText(
  34. image,
  35. f"pos: {joint}",
  36. (20, 20),
  37. FONT,
  38. 0.5,
  39. (190, 250, 100),
  40. 2,
  41. )
  42. cv2.imshow("frame", image)
  43. if cv2.waitKey(1) & 0xFF == ord("q"):
  44. break