Viam SDK
    Preparing search index...

    Class VisionClient

    A gRPC-web client for a Vision service.

    Implements

    • Vision
    Index

    Constructors

    Properties

    callOptions: CallOptions = ...
    name: string

    The name of the resource.

    Methods

    • 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[];
              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,
      });

      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.

    • 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;
              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>