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

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