Configure Drawing with a Lua Script

The Draw transformation task draws regions on images or video frames. This section demonstrates how to customize the regions that are drawn by using a Lua script.

The Lua script that you write must define a function with the name draw. The function is passed each record from the input track. For example, the following function draws an ellipse on each record from the ResultWithSource track produced by face detection:

function draw(record)
   drawEllipse(record.FaceResultAndImage.face.ellipse, 3, rgb(255,255,255))
end

For information about the Lua functions that you can use to draw regions on images and video frames, refer to the Media Server Reference.

To configure drawing with a Lua script

  1. Create a new configuration to send to Media Server with the process action, or open an existing configuration that you want to modify.

  2. In the [Transform] section, add a new transformation task by setting the TransformEngineN parameter. You can give the task any name, for example:

    [Transform]
    TransformEngine0=Draw
  3. Create a new configuration section to contain the task settings and set the following parameters:

    Type The transformation engine to use. Set this parameter to Draw.
    Input The name of the track that contains the images to draw on, with region data. The track must supply records that contain both an image and at least one region.
    LuaScript The path of a Lua script to run to draw on the source images or video frames.

    For example:

    [Draw]
    Type=Draw
    Input=Demographics.ResultWithSource
    LuaScript=./configurations/drawDemographics.lua
  4. Save and close the configuration file. HPE recommends that you save your configuration files in the location specified by the ConfigDirectory parameter.

 


_HP_HTML5_bannerTitle.htm