Viam SDK
    Preparing search index...

    Class VisionClient

    A gRPC-web client for a Vision service.

    Implements

    • Vision
    Index
    callOptions: CallOptions = ...
    name: string

    The name of the resource.

    • Returns the requested image, classifications, detections, and 3d point cloud objects in the next image given a camera.

      Parameters

      • cameraName: string

        The name of the camera to use for classification, detection, and segmentation.

      • opts: CaptureAllOptions

        The fields desired in the response.

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

      Returns Promise<
          {
              classifications: visionApi.Classification[];
              detections: visionApi.Detection[];
              detections3d: visionApi.Detection3D[];
              extra: Struct
              | undefined;
              image: Image | undefined;
              objectPointClouds: commonApi.PointCloudObject[];
          },
      >

      • The requested image, classifications, detections, and 3d point cloud objects.
      const vision = new VIAM.VisionClient(machine, 'my_vision');
      const captureAll = await vision.captureAllFromCamera('my_camera', {
      returnImage: true,
      returnClassifications: true,
      returnDetections: true,
      returnObjectPointClouds: true,
      returnDetections3d: true,
      });

      For more information, see Vision API.

    • Send/Receive arbitrary commands to the resource.

      Parameters

      • command: Struct | Record<string, JsonValue>

        The command to execute. Accepts either a Struct or a plain object, which will be converted automatically.

      • callOptions: CallOptions = ...

      Returns Promise<JsonValue>

      // Plain object (recommended)
      const result = await resource.doCommand({
      myCommand: { key: 'value' },
      });

      // Struct (still supported)
      import { Struct } from '@viamrobotics/sdk';

      const result = await resource.doCommand(Struct.fromJson({ myCommand: { key: 'value' } }));
    • Get a list of classifications in the given image.

      Parameters

      • image: Uint8Array

        The image from which to get classifications.

      • width: number

        The width of the image.

      • height: number

        The height of the image.

      • mimeType: MimeType

        The MimeType of the image.

      • count: number

        The number of Classifications requested.

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

      Returns Promise<visionApi.Classification[]>

      • The list of Classifications.
      const camera = new VIAM.CameraClient(machine, 'my_camera');
      const vision = new VIAM.VisionClient(machine, 'my_vision');

      const { images } = await camera.getImages();
      const classifications = await vision.getClassifications(
      images[0].image,
      600,
      600,
      images[0].mimeType,
      10,
      );

      For more information, see Vision API.

    • Get a list of classifications in the next image given a camera.

      Parameters

      • cameraName: string

        The name of the camera to use for classification.

      • count: number

        The number of Classifications requested.

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

      Returns Promise<visionApi.Classification[]>

      • The list of Classifications.
      const vision = new VIAM.VisionClient(machine, 'my_vision');
      const classifications = await vision.getClassificationsFromCamera('my_camera', 10);

      For more information, see Vision API.

    • Get a list of detections in the given image.

      Parameters

      • image: Uint8Array

        The image from which to get detections.

      • width: number

        The width of the image.

      • height: number

        The height of the image.

      • mimeType: MimeType

        The MimeType of the image.

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

      Returns Promise<visionApi.Detection[]>

      • The list of Detections.
      const camera = new VIAM.CameraClient(machine, 'my_camera');
      const vision = new VIAM.VisionClient(machine, 'my_vision');

      const { images } = await camera.getImages();
      const detections = await vision.getDetections(
      images[0].image,
      600,
      600,
      images[0].mimeType,
      );

      For more information, see Vision API.

    • Returns the objects the vision service perceives through the specified camera. Each detection is a tree of transforms, root first: the root is parented to a frame the machine already knows, typically the camera, and every later transform is parented to the root or an earlier transform. Each transform's geometry is expressed relative to that transform's own origin.

      Parameters

      • cameraName: string

        The name of the camera.

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

      Returns Promise<visionApi.Detection3D[]>

      • The list of Detection3Ds
      const vision = new VIAM.VisionClient(machine, 'my_vision');
      const detections = await vision.getDetections3D('my_camera');

      For more information, see Vision API.

    • Get a list of detections in the next image given a camera.

      Parameters

      • cameraName: string

        The name of the camera to use for detection.

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

      Returns Promise<visionApi.Detection[]>

      • The list of Detections.
      const vision = new VIAM.VisionClient(machine, 'my_vision');
      const detections = await vision.getDetectionsFromCamera('my_camera');

      For more information, see Vision API.

    • Returns a list of the 3D point cloud objects and associated metadata in the latest picture obtained from the specified 3D camera.

      Parameters

      • cameraName: string

        The name of the camera.

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

      Returns Promise<commonApi.PointCloudObject[]>

      • The list of PointCloudObjects
      const vision = new VIAM.VisionClient(machine, 'my_vision');
      const pointCloudObjects = await vision.getObjectPointClouds('my_camera');

      For more information, see Vision API.

    • Returns an object describing the properties of the vision service, namely booleans indicating whether classifications, detections, and 3d segmentation are supported.

      Parameters

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

      Returns Promise<
          {
              classificationsSupported: boolean;
              defaultCamera: string
              | undefined;
              detections3dSupported: boolean;
              detectionsSupported: boolean;
              objectPointCloudsSupported: boolean;
          },
      >

      • The properties of the vision service
      const vision = new VIAM.VisionClient(machine, 'my_vision');
      const properties = await vision.getProperties();

      For more information, see Vision API.

    • Get the status of the resource.

      Parameters

      • callOptions: CallOptions = ...

      Returns Promise<JsonValue>