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.

README.md 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Dora Node for plotting data with OpenCV
  2. This node is used to plot a text and a list of bbox on a base image (ideal for object detection).
  3. # YAML
  4. ```yaml
  5. - id: opencv-plot
  6. build: pip install ../../node-hub/opencv-plot
  7. path: opencv-plot
  8. inputs:
  9. # image: Arrow array of size 1 containing the base image
  10. # bbox: Arrow array of bbox
  11. # text: Arrow array of size 1 containing the text to be plotted
  12. env:
  13. PLOT_WIDTH: 640 # optional, default is image input width
  14. PLOT_HEIGHT: 480 # optional, default is image input height
  15. ```
  16. # Inputs
  17. - `image`: Arrow array containing the base image
  18. ```python
  19. ## Image data
  20. image_data: UInt8Array # Example: pa.array(img.ravel())
  21. metadata = {
  22. "width": 640,
  23. "height": 480,
  24. "encoding": str, # bgr8, rgb8
  25. }
  26. ## Example
  27. node.send_output(
  28. image_data, {"width": 640, "height": 480, "encoding": "bgr8"}
  29. )
  30. ## Decoding
  31. storage = event["value"]
  32. metadata = event["metadata"]
  33. encoding = metadata["encoding"]
  34. width = metadata["width"]
  35. height = metadata["height"]
  36. if encoding == "bgr8":
  37. channels = 3
  38. storage_type = np.uint8
  39. frame = (
  40. storage.to_numpy()
  41. .astype(storage_type)
  42. .reshape((height, width, channels))
  43. )
  44. ```
  45. - `bbox`: an arrow array containing the bounding boxes, confidence scores, and class names of the detected objects
  46. ```Python
  47. bbox: {
  48. "bbox": np.array, # flattened array of bounding boxes
  49. "conf": np.array, # flat array of confidence scores
  50. "labels": np.array, # flat array of class names
  51. }
  52. encoded_bbox = pa.array([bbox], {"format": "xyxy"})
  53. decoded_bbox = {
  54. "bbox": encoded_bbox[0]["bbox"].values.to_numpy().reshape(-1, 4),
  55. "conf": encoded_bbox[0]["conf"].values.to_numpy(),
  56. "labels": encoded_bbox[0]["labels"].values.to_numpy(zero_copy_only=False),
  57. }
  58. ```
  59. - `text`: Arrow array containing the text to be plotted
  60. ```python
  61. text: str
  62. encoded_text = pa.array([text])
  63. decoded_text = encoded_text[0].as_py()
  64. ```
  65. ## License
  66. This project is licensed under Apache-2.0. Check out [NOTICE.md](../../NOTICE.md) for more information.