Added in API level 8

GestureUtils


class GestureUtils
kotlin.Any
   ↳ android.gesture.GestureUtils

Utility functions for gesture processing & analysis, including methods for:

  • feature extraction (e.g., samplers and those for calculating bounding boxes and gesture path lengths);
  • geometric transformation (e.g., translation, rotation and scaling);
  • gesture similarity comparison (e.g., calculating Euclidean or Cosine distances between two gestures).

Summary

Public methods
static OrientedBoundingBox!

Computes an oriented, minimum bounding box of a set of points.

static OrientedBoundingBox!

Computes an oriented, minimum bounding box of a set of points.

static FloatArray!
spatialSampling(gesture: Gesture!, bitmapSize: Int)

Samples the gesture spatially by rendering the gesture into a 2D grayscale bitmap.

static FloatArray!
spatialSampling(gesture: Gesture!, bitmapSize: Int, keepAspectRatio: Boolean)

Samples the gesture spatially by rendering the gesture into a 2D grayscale bitmap.

static FloatArray!
temporalSampling(stroke: GestureStroke!, numPoints: Int)

Samples a stroke temporally into a given number of evenly-distributed points.

Public methods

computeOrientedBoundingBox

Added in API level 8
static fun computeOrientedBoundingBox(originalPoints: ArrayList<GesturePoint!>!): OrientedBoundingBox!

Computes an oriented, minimum bounding box of a set of points.

Parameters
originalPoints ArrayList<GesturePoint!>!:
Return
OrientedBoundingBox! an oriented bounding box

computeOrientedBoundingBox

Added in API level 8
static fun computeOrientedBoundingBox(originalPoints: FloatArray!): OrientedBoundingBox!

Computes an oriented, minimum bounding box of a set of points.

Parameters
originalPoints FloatArray!:
Return
OrientedBoundingBox! an oriented bounding box

spatialSampling

Added in API level 8
static fun spatialSampling(
    gesture: Gesture!,
    bitmapSize: Int
): FloatArray!

Samples the gesture spatially by rendering the gesture into a 2D grayscale bitmap. Scales the gesture to fit the size of the bitmap. The scaling does not necessarily keep the aspect ratio of the gesture.

Parameters
gesture Gesture!: the gesture to be sampled
bitmapSize Int: the size of the bitmap
Return
FloatArray! a bitmapSize x bitmapSize grayscale bitmap that is represented as a 1D array. The float at index i represents the grayscale value at pixel [i%bitmapSize, i/bitmapSize]

spatialSampling

Added in API level 8
static fun spatialSampling(
    gesture: Gesture!,
    bitmapSize: Int,
    keepAspectRatio: Boolean
): FloatArray!

Samples the gesture spatially by rendering the gesture into a 2D grayscale bitmap. Scales the gesture to fit the size of the bitmap.

Parameters
gesture Gesture!: the gesture to be sampled
bitmapSize Int: the size of the bitmap
keepAspectRatio Boolean: if the scaling should keep the gesture's aspect ratio
Return
FloatArray! a bitmapSize x bitmapSize grayscale bitmap that is represented as a 1D array. The float at index i represents the grayscale value at pixel [i%bitmapSize, i/bitmapSize]

temporalSampling

Added in API level 8
static fun temporalSampling(
    stroke: GestureStroke!,
    numPoints: Int
): FloatArray!

Samples a stroke temporally into a given number of evenly-distributed points.

Parameters
stroke GestureStroke!: the gesture stroke to be sampled
numPoints Int: the number of points
Return
FloatArray! the sampled points in the form of [x1, y1, x2, y2, ..., xn, yn]