Class CameraClient

A gRPC-web client for the Camera component.

Implements

Constructors

Properties

callOptions: CallOptions = ...
name: string

The name of the resource.

Methods

  • Send/Receive arbitrary commands to the resource.

    Parameters

    • command: Struct

      The command to execute.

    • callOptions: CallOptions = ...

    Returns Promise<JsonValue>

    const result = await resource.doCommand({
    name: 'myCommand',
    args: { key: 'value' },
    });
  • Get the geometries of the component in their current configuration

    Parameters

    • extra: {} = {}
    • callOptions: CallOptions = ...

    Returns Promise<commonApi.Geometry[]>

  • Return a frame from a camera.

    Parameters

    • mimeType: MimeType = ''

      A specific MIME type to request. This is not necessarily the same type that will be returned.

    • extra: {} = {}
    • callOptions: CallOptions = ...

    Returns Promise<Uint8Array>

    const camera = new VIAM.CameraClient(machine, 'my_camera');
    const image = await camera.getImage();

    // Convert Uint8Array to base64
    const base64Image = btoa(
    Array.from(image)
    .map((byte) => String.fromCharCode(byte))
    .join('')
    );

    // Convert image to base64 and display it
    const imageElement = document.createElement('img');
    imageElement.src = `data:image/jpeg;base64,${base64Image}`;
    const imageContainer = document.getElementById('#imageContainer');
    if (imageContainer) {
    imageContainer.innerHTML = '';
    imageContainer.appendChild(imageElement);
    }

    For more information, see Camera API.

  • Return a point cloud from a camera.

    Parameters

    • extra: {} = {}
    • callOptions: CallOptions = ...

    Returns Promise<Uint8Array>

    const camera = new VIAM.CameraClient(machine, 'my_camera');
    const pointCloud = await camera.getPointCloud();

    For more information, see Camera API.

  • Render a frame from a camera to an HTTP response.

    Parameters

    • mimeType: MimeType = ''

      A specific MIME type to request. This is not necessarily the same type that will be returned.

    • extra: {} = {}
    • callOptions: CallOptions = ...

    Returns Promise<Blob>

    const camera = new VIAM.CameraClient(machine, 'my_camera');
    const mimeType = 'image/jpeg';
    const image = await camera.renderFrame(mimeType);

    For more information, see Camera API.

MMNEPVFCICPMFPCPTTAAATR