The processframe function is responsible for performing AI operations on the frame, such as object detection and pose estimation, and returning the results of those operations.

Function Defintion

The function accepts a single argument of type Frame. This object provides an easy-to-use interface to the Guru AI Platform. The remaining pages in this section document common types you can use with Frame.

/**
 * @param {Frame} frame - The frame to process
 * @return {*} - The output of processing for this frame.
 */
async function processFrame(frame) {
  return {};
}

class Frame {

  /**
   * Find objects of a specific type within the video.
   *
   * @param {(string|Array.<string>)} objectTypes - The type of the object to find.
   *    Can either be a string, in which case objects of a single type will be found, or an array of strings, in which case multiple object types will be found.
   * @param {boolean} keypoints - Flag indicating whether to include keypoints in the results. Defaults to true.
   * @return {Array.<FrameObject>} A list of FrameObject instances matching the given criteria.
   */
  async findObjects(objectTypes, {keypoints = true} = {});
}

Example

Find all of the people in the frame and outputs their location

async function processFrame(frame) {
  const objects = await frame.findObjects("person");

  return { people: objects };
}