Skip to main content

Dora Node for plotting text and bbox on image with OpenCV

Project description

Dora Node for plotting data with OpenCV

This node is used to plot a text and a list of bbox on a base image (ideal for object detection).

YAML

- id: opencv-plot
  build: pip install ../../node-hub/opencv-plot
  path: opencv-plot
  inputs:
    # image: Arrow array of size 1 containing the base image
    # bbox: Arrow array of bbox
    # text: Arrow array of size 1 containing the text to be plotted

  env:
    PLOT_WIDTH: 640 # optional, default is image input width
    PLOT_HEIGHT: 480 # optional, default is image input height

Inputs

  • image: Arrow array containing the base image
## Image data
image_data: UInt8Array # Example: pa.array(img.ravel())
metadata = {
  "width": 640,
  "height": 480,
  "encoding": str, # bgr8, rgb8
}

## Example
node.send_output(
  image_data, {"width": 640, "height": 480, "encoding": "bgr8"}
  )

## Decoding
storage = event["value"]

metadata = event["metadata"]
encoding = metadata["encoding"]
width = metadata["width"]
height = metadata["height"]

if encoding == "bgr8":
    channels = 3
    storage_type = np.uint8

frame = (
    storage.to_numpy()
    .astype(storage_type)
    .reshape((height, width, channels))
)
  • bbox: an arrow array containing the bounding boxes, confidence scores, and class names of the detected objects
bbox: {
    "bbox": np.array,  # flattened array of bounding boxes
    "conf": np.array,  # flat array of confidence scores
    "labels": np.array,  # flat array of class names
}

encoded_bbox = pa.array([bbox], {"format": "xyxy"})

decoded_bbox = {
    "bbox": encoded_bbox[0]["bbox"].values.to_numpy().reshape(-1, 4),
    "conf": encoded_bbox[0]["conf"].values.to_numpy(),
    "labels": encoded_bbox[0]["labels"].values.to_numpy(zero_copy_only=False),
}
  • text: Arrow array containing the text to be plotted
text: str

encoded_text = pa.array([text])

decoded_text = encoded_text[0].as_py()

Example

Check example at examples/python-dataflow

License

This project is licensed under Apache-2.0. Check out NOTICE.md for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencv_plot-0.3.7.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

opencv_plot-0.3.7-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file opencv_plot-0.3.7.tar.gz.

File metadata

  • Download URL: opencv_plot-0.3.7.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for opencv_plot-0.3.7.tar.gz
Algorithm Hash digest
SHA256 0e678d9ecbe4b63bdf017d8980667f04df2de442aeb31876563fdccb06d2ebde
MD5 9c6cf65e5190a15c4833dc3def9039c3
BLAKE2b-256 dfc5765b71a787bf8e1d44dca30f62fdc1256c66e9340d11a2bc7d28c55ffdf1

See more details on using hashes here.

File details

Details for the file opencv_plot-0.3.7-py3-none-any.whl.

File metadata

  • Download URL: opencv_plot-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for opencv_plot-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 eb875eff501e61e90aa98e0a9abc801524c90eb05b6494bc41ef16ded9c47ed0
MD5 d32f59c3aff36e3bf523136be1f9ac26
BLAKE2b-256 a67b826ecd508ca6f65ae483bcb3aedb0da11991850948ec4c4b65a0b53b4f3c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page