Skip to main content

ImageEncode

Encode the image metadata as a JPEG image.

This module provides a pipeline element to encode the image metadata as a JPEG image. There is an optional argument to specify if you want to skip to the encoding if parts of the metadata are missing.

Examples:

REST API:

WIP

Configuration File:

Encode all frames:

```yaml
source:
- address: videos/sd_london_station_sd.mp4
type: file
elements:
- name: image-encoder
```

Only encode if person objects are present:

```yaml
source:
- address: videos/sd_london_station_sd.mp4
type: file
elements:
- name: infer
args:
model: person-detection-nano
score_threshold: 0.3
iou_threshold: 0.3
- name: image-encoder
args:
labels: [person]
```

Only encode if person and bus objects are present:

```yaml
source:
- address: videos/sd_london_station_sd.mp4
type: file
elements:
- name: infer
args:
model: coco-nano
score_threshold: 0.3
iou_threshold: 0.3
- name: image-encoder
args:
labels: [person,bus]
```

ImageEncode Objects

class ImageEncode(Element)

Encode a frame as a JPEG image.

This element encodes a frame to a JPEG image if the frame has certain metadata labels.

Attributes:

  • name str - The name of the element.
  • labels list[str] - The item label(s) to require before encoding.

Examples:

All:

```python
ele = ImageEncode()
```

person:

```python
ele = ImageEncode(labels=["person"])
```

person and bus:

```python
ele = ImageEncode(labels=["person","bus"])
```

process

def process(meta: PipelineMetadata)

Process the metadata by converting the frame to a JPEG image.

This is the main function for this element. It will process the metadata by first comparing the fields of the metadata to the item(s) to skip encode. If an item is found than the frame will not be encoded.

Arguments:

  • meta PipelineMetadata - The metadata to process.

Returns:

  • meta PipelineMetadata - The processed metadata.

Examples:

```python
meta = ImageEncode().process(meta)
```