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.

webcam.py 660 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import time
  4. import cv2
  5. from dora import Node
  6. node = Node()
  7. video_capture = cv2.VideoCapture(0)
  8. start = time.time()
  9. # Run for 20 seconds
  10. while time.time() - start < 10:
  11. # Wait next dora_input
  12. event = node.next()
  13. match event["type"]:
  14. case "INPUT":
  15. ret, frame = video_capture.read()
  16. if ret:
  17. node.send_output("image", cv2.imencode(".jpg", frame)[1].tobytes())
  18. case "STOP":
  19. print("received stop")
  20. break
  21. case other:
  22. print("received unexpected event:", other)
  23. break
  24. video_capture.release()

DORA (Dataflow-Oriented Robotic Architecture) is middleware designed to streamline and simplify the creation of AI-based robotic applications. It offers low latency, composable, and distributed datafl