Skip to main content

operations

operations indicates visual operations to be performed on images, videos, and other visual objects, either at insertion or at retrieval time.

operations is composed by an array of elements "operation". Each operation has a "type" (which is the name of the operation) and parameters specific for that operation.

At least one operation must be defined in the array.

Operations are guaranteed to be performed in the specified order.

Not all the parameters are required for each operation. Below we detail the operations supported for Images (AddImage, FindImage), those operations supported for Videos (AddVideo, FindVideo), and the operations that are common for both Images and Videos.

Common Operations and Parameters

  • threshold:

    • "type": "threshold"
    • "value": [0,255]. Value of the threshold below which all pixel values are zeroed.
  • crop:

    • "type": "crop"
    • "x": specify the starting position x (row).
    • "y": specify the starting position y (column).
    • "width": specify the width of the crop.
    • "height": specify the height of the crop.
  • resize:

    • "type": "resize"
    • "width": set the new image width.
    • "height": set the new image height.
    • "scale": specify the scale for resizing the image along both dimensions.
    • Either "scale" OR ("width" and/or "height") can be specified.
    • If only one dimension is specified (width or height), the other dimension will be scaled accordingly, keeping the image aspect ratio.

Extra Operations for Images

  • flip:

    • "type": "flip"

    • "code": Follows OpenCV convention:

      • 0 for Vertical flip
      • >0 for Horizontal flip
      • <0 for both
  • rotate:

    • "type": "rotate"
    • "angle": rotation angle, specified in counter-clockwise degrees.
    • "resize": {true, false}. Specifies whether the image will be resized so that the rotated image fits (resize = true), or if the image will be kept the same size (resize = false).

Extra Operations for Videos

  • interval:

    • "type": "interval"
    • "start": First frame.
    • "stop" : Last frame.
    • "step": Number of frames in between.
  • preview:

    • "type": "preview"
    • "max_frame_count": requested video will not exceed the specified frame count.
    • "max_time_fraction": requested video will not exceed the specified time fraction.
    • "max_time_offset": requested video will not exceed the specified time offset.
    • "max_size_mb": requested video will not exceed the specified size.

Example

# resize and threshold.
"operations": [
{
"type": "resize",
"height": 200,
"width": 200
},
{
"type": "threshold",
"value": 155
}
],

# resize along width dimension.
# this will scale height accordingly, keeping image aspect ratio.
# For example, if the original image is 1000x500 (hxw),
# the resulting image will be 200x100.
"operations": [
{
"type": "resize",
"width": 100
}
]

# rescale the image along both dimensions.
# For example, if the original image is 1000x500 (hxw),
# the resulting image will be 1500x750
"operations": [
{
"type": "resize",
"scale": 1.5
}
],

# crop and threshold.
"operations": [
{
"type": "crop",
"x": 255,
"y": 155,
"height": 10,
"width": 15
},
{
"type": "threshold",
"value": 155,
}
],

# interval
"operations": [
{
"type": "flip",
"code": 1 # Horizontal Flip
},
{
"type": "interval", # Interval Operation
"start": 20, # Start from the 20th frame
"stop": 200, # Stop at the 200th frame
"step": 5 # Pick 1 every 5 frames.
}
],


# resize and preview.
"operations": [
{
"type": "resize",
"height": 640,
"width": 480
},
{
"type": "preview", # Request an initial part of the
# Video that is
"max_time_offset": "00:00:30.000" # ... up to 30 seconds long,
"max_size_mb": 10, # ... up to 10 MB in size, and
"max_frame_count": 1000 # ... up to 1,000 frames large.
}
]