Interface Camera

Represents any physical hardware that can capture frames.

interface Camera {
    getGeometries: (extra?: Struct) => Promise<commonApi.Geometry[]>;
    getImage: (mimeType?: MimeType, extra?: Struct) => Promise<Uint8Array>;
    getPointCloud: (extra?: Struct) => Promise<Uint8Array>;
    getProperties: () => Promise<Properties>;
    name: string;
    renderFrame: (mimeType?: MimeType, extra?: Struct) => Promise<Blob>;
    doCommand(command: Struct): Promise<JsonValue>;
}

Hierarchy (View Summary, Expand)

Implemented by

Properties

getGeometries: (extra?: Struct) => Promise<commonApi.Geometry[]>

Get the geometries of the component in their current configuration

getImage: (mimeType?: MimeType, extra?: Struct) => Promise<Uint8Array>

Return a frame from a camera.

Type declaration

    • (mimeType?: MimeType, extra?: Struct): Promise<Uint8Array>
    • Parameters

      • OptionalmimeType: MimeType

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

      • Optionalextra: Struct

      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.

getPointCloud: (extra?: Struct) => Promise<Uint8Array>

Return a point cloud from a camera.

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

For more information, see Camera API.

getProperties: () => Promise<Properties>

Return the camera properties.

const camera = new VIAM.CameraClient(machine, 'my_camera');
const properties = await camera.getProperties();

For more information, see Camera API.

name: string

The name of the resource.

renderFrame: (mimeType?: MimeType, extra?: Struct) => Promise<Blob>

Render a frame from a camera to an HTTP response.

Type declaration

    • (mimeType?: MimeType, extra?: Struct): Promise<Blob>
    • Parameters

      • OptionalmimeType: MimeType

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

      • Optionalextra: Struct

      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.

Methods

  • Send/Receive arbitrary commands to the resource.

    Parameters

    • command: Struct

      The command to execute.

    Returns Promise<JsonValue>

    const result = await resource.doCommand({
    name: 'myCommand',
    args: { key: 'value' },
    });
MMNEPVFCICPMFPCPTTAAATR