ImageEncode
Encode the image metadata as a JPEG image.
This module provides an 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:
short-from : image-encoder
, image-encoder:<s/l-item(s)>
Encode all frames:
source:
- address: https://youtu.be/jY86pXeTOLw
- type: youtube
pipeline:
- image-encoder
Only encode if person objects are present:
source:
- address: https://youtu.be/jY86pXeTOLw
- type: youtube
pipeline:
- person-detection-nano:a:0.3:0.3
- image-encoder:person
Only encode if person and bus objects are present:
source:
- address: https://youtu.be/jY86pXeTOLw
- type: youtube
pipeline:
- coco-nano:a:0.3:0.3
- image-encoder:[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 metadata is it does not want to skip.
Attributes:
name
str - The name of the element.item
Union[str, List[str]] - The item(s) to skip encode.
Examples:
All:
ele = ImageEncode()
person:
ele = ImageEncode("person")
person and bus:
ele = ImageEncode(["person","bus"])
extract_params
@staticmethod
def extract_params(model_params)
Extract the parameters for this element.
Arguments:
model_params
List[str] - The parameters for this element.
Returns:
item
Union[str, List[str]] - The item(s) to skip encode.
Raises:
ExtractParameterException
- If the parameters are not valid.
Examples:
params = ImageEncode.extract_params(["image-encoder", "[person, bus]"])
ele = ImageEncode(params)
process
@parallel
def process(meta)
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
dict - The metadata to process.
Returns:
meta
dict - The processed metadata.
Examples:
ele = ImageEncode()
meta = ele.process(meta)