Class Cast

java.lang.Object
me.clarius.sdk.Cast

public class Cast extends Object
Java interface for Clarius Cast.
  • Constructor Details

    • Cast

      public Cast(android.content.Context context, Cast.Listener listener)
      Deprecated.
      This constructor is no longer acceptable, use Cast(String, Listener) instead.

      The Context object was used to obtain the path to the native JNI libraries, the new constructor lets user specify their own path if needed. The default path is: requireContext().getApplicationInfo().nativeLibraryDir.

      Deprecated in version 10.3.0.

      Load the Clarius Cast library.
      Parameters:
      context - the application context.
      listener - API callbacks.
    • Cast

      public Cast(String nativeLibraryDir, Cast.Listener listener)
      Load the Clarius Cast library.
      Parameters:
      nativeLibraryDir - full path to the directory where native JNI libraries are stored. The Clarius Cast library will look for Qt plugins inside this directory. The path can be obtained from requireContext().getApplicationInfo().nativeLibraryDir.
      listener - API callbacks.
  • Method Details

    • release

      public void release()
      Unload the Clarius Cast library, any subsequent call will be no-op.
    • initialize

      public void initialize(String sslDir, Cast.BooleanResult resultFn)
      Initialize the Clarius Cast library to enable connection.
      Parameters:
      sslDir - the directory to store security keys.
      resultFn - the result callback.
    • isInitialized

      public boolean isInitialized()
      Check if Clarius Cast has been initialized.
      Returns:
      true if Clarius Cast has been initialized.
    • connect

      public void connect(String ipAddress, int port, Optional<Long> networkID, String certificate, Cast.ConnectionResult resultFn)
      Connect to a probe that is on the same network as the caller.

      NOTE: The network ID is used when attempting to connect to the probe's Wi-Fi that was auto-joined with Android Wi-Fi Network Request API. It can be obtained from the Network object obtained in the NetworkCallback.onAvailable() callback. It can also be obtained in the launch intent sent from the Clarius App in the Marketplace workflow.

      Parameters:
      ipAddress - the IP address of the probe.
      port - the probe's TCP port to connect to.
      networkID - the Wi-Fi network ID obtained when auto-joining Wi-Fi.
      certificate - the certificate for authenticating the probe.
      resultFn - the result callback.
    • disconnect

      public void disconnect(Cast.BooleanResult resultFn)
      Disconnect from an existing connection.
      Parameters:
      resultFn - the result callback.
    • isConnected

      public boolean isConnected()
      Check if Clarius Cast is currently connected to a probe.
      Returns:
      true if Clarius Cast is connected to a probe.
    • setOutputSize

      public void setOutputSize(int width, int height)
      Set the dimensions of the output display for scan conversion.

      The output will always result in a 1:1 pixel ratio, depending on geometry of scanning array, and parameters the frame will have various sizes of black borders around the image.

      Parameters:
      width - the number of horizontal pixels in the output.
      height - the number of vertical pixels in the output.
    • separateOverlays

      public void separateOverlays(boolean enable)
      Set a flag to separate overlays into separate images.

      For example if color/power Doppler or strain imaging is enabled, two callbacks will be generated: one with the grayscale frame and the other with the overlay.

      Parameters:
      enable - the enable flag for separating overlays.
    • setFormat

      public void setFormat(ImageFormat format)
      Set the format for processed images, by default the format will be uncompressed ARGB32.
      Parameters:
      format - the format of the image.
    • userFunction

      public void userFunction(UserFunction userFunction, double value, Cast.BooleanResult resultFn)
      Perform a user function on a connected probe.
      Parameters:
      userFunction - the command to run.
      value - the value to set if the function supports setting of values, see UserFunction enumerations for details.
      resultFn - the result callback.
    • getProbeInfo

      public void getProbeInfo(Cast.ProbeInfoResult resultFn)
      Retrieve the probe info.
      Parameters:
      resultFn - the result callback.
    • getFirmwareVersion

      public void getFirmwareVersion(Platform platform, Cast.FirmwareVersionResult resultFn)
      Retrieve the firmware version for a given platform.
      Parameters:
      platform - the platform for which to retrieve the firmware version.
      resultFn - the result callback.
    • requestRawData

      public void requestRawData(long start, long end, Cast.RequestRawDataCallback resultFn)
      Request raw data from the probe.

      NOTE: probe must be frozen and in a raw data buffering mode in order for the call to succeed.

      Usage: 1. Request raw data with requestRawData() 2. On success, read raw data with readRawData()

      Parameters:
      start - the first frame to request, as determined by timestamp in nanoseconds, set start and end to 0 to requests all data in buffer.
      end - the last frame to request, as determined by timestamp in nanoseconds, set start and end to 0 to requests all data in buffer.
      resultFn - the result callback.
    • readRawData

      public void readRawData(Cast.ReadRawDataCallback resultFn)
      Retrieve raw data from a previous request.

      NOTE: call requestRawData() first.

      Parameters:
      resultFn - the result callback.
    • startCapture

      public void startCapture(long timestamp, Cast.StartCaptureResult resultFn)
      Create a capture request locally for sending to the app.

      NOTE: not strictly required for probe to be frozen, but it gives a lower chance of synchronization errors.

      Parameters:
      timestamp - the frame to request, in nanoseconds.
      resultFn - the result callback.
    • addImageOverlay

      public boolean addImageOverlay(int captureID, byte[] bytes, int width, int height, float red, float green, float blue, float alpha)
      Add an image overlay to a started capture
      Parameters:
      captureID - the ID of the capture which is to be added to
      bytes - the image bytes (8-bit grayscale)
      width - width of the image data which is to be added; must match the width from setOutputSize
      height - height of the image data which is to be added; must match the height from setOutputSize
      red - the value of red use in colorizing the overlay, should be between 0.0 and 1.0
      green - the value of green use in colorizing the overlay, should be between 0.0 and 1.0
      blue - the value of blue use in colorizing the overlay, should be between 0.0 and 1.0
      alpha - the value of alpha (opacity) use in colorizing the overlay, should be between 0.0 and 1.0
      Returns:
      true the image overlay was successfully added to the capture.
    • addLabelOverlay

      public boolean addLabelOverlay(int captureID, String text, double x, double y, double width, double height)
      Add a label overlay to a started capture
      Parameters:
      captureID - the ID of the capture which is to be added to
      text - string of the label to be added
      x - x-position of the label in pixels (same scale as the width from setOutputSize)
      y - y-position of the label in pixels (same scale as the height from setOutputSize)
      width - width of the label in pixels (same scale as the width from setOutputSize)
      height - height of the label in pixels (same scale as the height from setOutputSize)
      Returns:
      true the label overlay was successfully added to the capture.
    • addMeasurement

      public boolean addMeasurement(int captureID, MeasurementType type, String label, PointF[] points)
      Add a measurement to a started capture
      Parameters:
      captureID - the ID of the capture which is to be added to
      type - the type of measurement to be added
      label - string label for the measurement
      points - NSValue holding an array of CGPoint/NSPoint in pixels (same scale as the width/height from cusCastInit)
      Returns:
      true the measurement overlay was successfully added to the capture.
    • finishCapture

      public void finishCapture(int captureID, Cast.BooleanResult resultFn)
      Finish a previously started capture and send it to the app.

      NOTE: call startCapture() first.

      Parameters:
      captureID - the ID of the capture which is to be finished
      resultFn - the result callback.