Added in API level 8

GestureUtils


public final class GestureUtils
extends Object

java.lang.Object
   ↳ 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 computeOrientedBoundingBox(ArrayList<GesturePoint> originalPoints)

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

static OrientedBoundingBox computeOrientedBoundingBox(float[] originalPoints)

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

static float[] spatialSampling(Gesture gesture, int bitmapSize)

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

static float[] spatialSampling(Gesture gesture, int bitmapSize, boolean keepAspectRatio)

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

static float[] temporalSampling(GestureStroke stroke, int numPoints)

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

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

computeOrientedBoundingBox

Added in API level 8
public static OrientedBoundingBox computeOrientedBoundingBox (ArrayList<GesturePoint> originalPoints)

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

Returns
OrientedBoundingBox an oriented bounding box

computeOrientedBoundingBox

Added in API level 8
public static OrientedBoundingBox computeOrientedBoundingBox (float[] originalPoints)

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

Returns
OrientedBoundingBox an oriented bounding box

spatialSampling

Added in API level 8
public static float[] spatialSampling (Gesture gesture, 
                int bitmapSize)

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

Returns
float[] 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
public static float[] spatialSampling (Gesture gesture, 
                int bitmapSize, 
                boolean keepAspectRatio)

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

Returns
float[] 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
public static float[] temporalSampling (GestureStroke stroke, 
                int numPoints)

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

Returns
float[] the sampled points in the form of [x1, y1, x2, y2, ..., xn, yn]