Pipeline

@RequiresApi(value = 27)
class Pipeline : BaseHandle

SpatialML pipeline.

Each pipeline defines a computation graph of tensors. A pipeline will not be run until it is submitted, and each submission will schedule one execution of the whole pipeline. One submitted execution will be put onto one thread in the backend, so that multiple submitted pipelines can be run concurrently.

Throws

If the usage is not allowed by the SpatialML run-time Framework, or if the framework encounter internal error and cannot perform the requested behavior.

Types

Link copied to clipboard

Color conversion types.

Link copied to clipboard

Model inference type, determining what inference engine the algorithm model will be run on, and what hardware backend will be used to accelerate the model inference.

Link copied to clipboard
class ModelNodeEncoding(val nodeName: String, val tensor: Tensor)

The association of a node in a model (QNN, TFLite, etc.) computation graph and a pipeline tensor.

Link copied to clipboard

Normalization type for normalize.

Link copied to clipboard

Norm type for norm.

Link copied to clipboard
class RunTask(pipeline: Pipeline, placeholderMap: Map<PipelineTensorPlaceholder, GlobalTensor>, condition: GlobalTensor?, waitFor: Pipeline.RunTask?)

The handle to one submitted pipeline run task.

Link copied to clipboard

Enum to determine how a matrix will be sorted.

Link copied to clipboard
Link copied to clipboard

Vertical alignment that can be used to update SceneGraphProperty.Text.VerticalAlignment.

Properties

Link copied to clipboard

The BaseHandle's implementation's destructor.

Link copied to clipboard

A helper getter to create a new local tensor in-place for an android android.graphics.Color. The R, G, B, and A values of the provided color will be set as the tensor's content automatically.

A helper getter to create a new local tensor in-place for a android android.graphics.Point. The X and Y values of the provided point will be set as the tensor's content automatically.

val Array<Color>.tensor: PipelineTensor

A helper getter to create a new local tensor in-place for an array of android.graphics.Color. The R, G, B, and A values of the provided colors will be set as the tensor's content automatically.

val Array<Point>.tensor: PipelineTensor

A helper getter to create a new local tensor in-place for an array of android android.graphics.Point. The X and Y values of the provided points will be set as the tensor's content automatically.

A helper getter to create a new local tensor in-place for a single byte scalar.

A helper getter to create a new local tensor in-place for a single double scalar.

val DoubleArray.tensor: PipelineTensor

A helper getter to create a new local tensor in-place for double array

A helper getter to create a new local tensor in-place for a single float scalar.

val FloatArray.tensor: PipelineTensor

A helper getter to create a new local tensor in-place for a float array.

A helper getter to create a new local tensor in-place for a single int scalar.

val IntArray.tensor: PipelineTensor

A helper getter to create a new local tensor in-place for an int array.

A helper getter to create a new local tensor in-place for a single short scalar.

val ShortArray.tensor: PipelineTensor

A helper getter to create a new local tensor in-place for a short array.

A helper getter to create a new local tensor in-place for a string.

Functions

Link copied to clipboard
fun applyAffine(affineMatrix: Tensor, srcImage: Tensor, affinedImage: Tensor)

Apply the affine transform on 2D image.

Link copied to clipboard
fun applyAffinePoint(affineMatrix: Tensor, srcPoints: Tensor, affinedPoints: Tensor)

Apply the affine transform on 2D points rather than 2D images.

Link copied to clipboard
fun argmax(source: Tensor, result: Tensor)

Compute argmax operation on tensor, giving the indices of max element of the input tensor per channel.

Link copied to clipboard
fun arithmetic(expression: String, operands: Array<Tensor>, result: Tensor)

Defines an arithmetic operator to the pipeline. An arithmetic operator takes in an array of PipelineTensor (size of which must be no more than 10), and write the arithmetic result into result. The arithmetic expression to be executed is defined by expression.

Link copied to clipboard
fun bitwiseAnd(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an bitwise-and of two input tensors.

Link copied to clipboard
fun bitwiseOr(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an bitwise-or of two input tensors.

Link copied to clipboard
fun bytewiseAll(operand: Tensor, result: Tensor)

Perform a byte-wise all on all the values constituting the tensor.

Link copied to clipboard
fun bytewiseAny(operand: Tensor, result: Tensor)

Perform a byte-wise any on all the values constituting the tensor.

Link copied to clipboard
fun convertColor(conversionType: Pipeline.ColorConversion, source: Tensor, result: Tensor)
fun convertColor(opencvConvertStr: String, source: Tensor, result: Tensor)

Convert the color, e.g. RGB-to-Grayscale, RGB-to-BGR, etc.

Link copied to clipboard

Copy from a slice of one pipeline tensor to a slice of another tensor. The slice of the copy source must contain the same number of values as the total number of values in the copy destination.

Copy from one slice of a pipeline tensor to another. The slice of the copy source must contain the same number of values as the total number of values in the copy destination.

Copy from one pipeline tensor to a slice of another tensor. The slice of the copy source must contain the same number of values as the total number of values in the copy destination.

fun copy(src: Tensor, dst: Tensor)

Copy from one pipeline tensor to another. The two pipeline tensors, respectively denoted as src and dst, must have the same number of values.

Link copied to clipboard
fun elementwiseMax(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-max of two input tensors.

Link copied to clipboard
fun elementwiseMin(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-min of two input tensors.

Link copied to clipboard
fun elementwiseMultiply(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-multiplication of two input tensors.

Link copied to clipboard
fun equal(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-equal comparison of two input tensors.

Link copied to clipboard

Convenient method to directly create a slice of a GlobalTensor using bracket operators from a tensor. This operator overload allows SpatialML framework users to apply tensors output from previous steps as a dynamic slices.

operator fun GlobalTensor.get(vararg indexAndSkips: IntProgression): PipelineTensorSlice

Convenient method to directly create a slice of a GlobalTensor using bracket operators from IntProgression. Different from the overloaded method that uses IntRange as inputs, IntProgression allows skip and backward iteration. Similarly, there must be the same number of IntProgression inputs as the number of this tensor's dimensions

operator fun GlobalTensor.get(vararg indices: IntRange): PipelineTensorSlice

Convenient method to directly create a slice of a GlobalTensor using bracket operators from IntRanges like 0..5, 1..2.

Link copied to clipboard
fun getAffine(srcPoints: Tensor, affinedPoints: Tensor, affineMatrixResult: Tensor)

Compute the 2D affine transform between two triangles.

Link copied to clipboard
fun inversion(source: Tensor, result: Tensor)

Compute the matrix inversion.

Link copied to clipboard
fun largerEqual(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-large-equal comparison of two input tensors.

Link copied to clipboard
fun largerThan(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-large-than comparison of two input tensors.

Link copied to clipboard
fun makeTransform(rotationVec: Tensor?, translationVec: Tensor?, scaleVec: Tensor?, result: Tensor)

Compute the 4x4 transform matrix for translation, rotation and scale.

Link copied to clipboard

A helper function to create a new local tensor in-place for an android android.graphics.Color. The R, G, B, and A values of the provided color will be set as the tensor's content automatically.

A helper function to create a new local tensor in-place for a android android.graphics.Point. The X and Y values of the provided point will be set as the tensor's content automatically.

Create a new local tensor inside this pipeline. The tensor have memory allocated local to the pipeline.

fun newLocalTensor(colorArray: Array<Color>): PipelineTensorLocal

A helper function to create a new local tensor in-place for an array of android.graphics.Color. The R, G, B, and A values of the provided colors will be set as the tensor's content automatically.

fun newLocalTensor(point2Array: Array<Point>): PipelineTensorLocal

A helper function to create a new local tensor in-place for an array of android android.graphics.Point. The X and Y values of the provided points will be set as the tensor's content automatically.

A helper function to create a new local tensor in-place for a single character.

fun newLocalTensor(doubleVal: Double): PipelineTensorLocal

A helper function to create a new local tensor in-place for a single double scalar.

fun newLocalTensor(doubleVal: DoubleArray): PipelineTensorLocal

A helper function to create a new local tensor in-place for a double array.

fun newLocalTensor(floatVal: Float): PipelineTensorLocal

A helper function to create a new local tensor in-place for a single float scalar.

fun newLocalTensor(floatVal: FloatArray): PipelineTensorLocal

A helper function to create a new local tensor in-place for a float array.

A helper function to create a new local tensor in-place for a single int scalar.

fun newLocalTensor(intVal: IntArray): PipelineTensorLocal

A helper function to create a new local tensor in-place for an int array.

fun newLocalTensor(shortVal: Short): PipelineTensorLocal

A helper function to create a new local tensor in-place for a single short scalar.

fun newLocalTensor(shortVal: ShortArray): PipelineTensorLocal

A helper function to create a new local tensor in-place for a short array.

fun newLocalTensor(string: String): PipelineTensorLocal

A helper function to create a new local tensor in-place for a string.

Link copied to clipboard

Create a new placeholder tensor inside this pipeline. Different from a local tensor, a placeholder tensor has no local memory allocated in the pipeline's scope; on the contrary, the placeholder must refer to a compatible global tensor when the pipeline is submitted for execution.

Link copied to clipboard

Create a new placeholder tensor inside this pipeline with guarantee compatibility with the a GlobalTensor, i.e., the newly created placeholder share the same configuration with the GlobalTensor. Note: a placeholder tensor has no local memory allocated in the pipeline's scope; on the contrary, the placeholder must refer to a compatible global tensor when the pipeline is submitted for execution.

Link copied to clipboard
fun newSceneFromGLTF(gltfSceneMemory: SharedMemory): PipelineTensor

Create an SpatialML scene from a glTF file already loaded into SharedMemory. Similar to SpatialMLSession.newSceneFromGLTF but that one creates a global scene graph handle, so that multiple pipelines can share, whereas this method creates one scene graph local to the pipeline only.

Link copied to clipboard
fun nonMaximumSuppression(iou: Float, scores: Tensor, boxes: Tensor, scoresResult: Tensor? = null, boxesResult: Tensor? = null, indicesResult: Tensor? = null)

Run non-maximum-suppression (NMS) on 2D bounding boxes.

Link copied to clipboard
fun norm(type: Pipeline.NormType, srcTensor: Tensor, result: Tensor)

Compute the norm of a tensor.

Link copied to clipboard
fun normalize(type: Pipeline.NormalizeType, source: Tensor, alphaBeta: Tensor?, result: Tensor)

Normalize a tensor.

Link copied to clipboard
fun notEqual(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-not-equal comparison of two input tensors.

Link copied to clipboard
fun rectifiedVSTAccess(rightImageResult: Tensor?, leftImageResult: Tensor?, timestampResult: Tensor?, cameraMatrixResult: Tensor?)

Obtain the latest camera images. The images will be rectified internal against len distortion.

Link copied to clipboard
fun runModelInference(modelName: String, modelType: Pipeline.ModelInferenceType, modelBinary: SharedMemory, inputs: Array<Pipeline.ModelNodeEncoding>, outputs: Array<Pipeline.ModelNodeEncoding>)

Run the inference of an algorithm model provided in binary package.

Link copied to clipboard
fun singularValueDecomposition(source: Tensor, wResult: Tensor?, uResult: Tensor?, vtResult: Tensor?)

Perform singular value decomposition of a matrix.

Link copied to clipboard
fun smallerEqual(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-smaller-equal comparison of two input tensors.

Link copied to clipboard
fun smallerThan(tensor1: Tensor, tensor2: Tensor, result: Tensor)

Perform an elementwise-smaller-than comparison of two input tensors.

Link copied to clipboard
fun solvePnP(objPoints: Tensor, imgPoints: Tensor, camMatrix: Tensor, rotationVecResult: Tensor? = null, translationVecResult: Tensor? = null)

Run the OpenCV solve PnP algorithm. Solve PnP reverses the camera projection procedure: given the projected result (2D points) of the vertices of a mesh, and the original 3D coordinates of the mesh vertices corresponding to the mesh's local space, inferring the most likely pose of the mesh corresponding to the camera space.

Link copied to clipboard
fun sortMatrix(sortType: Pipeline.SortType, source: Tensor, sortedResult: Tensor?, indexResult: Tensor?)

Sort a matrix, column-by-column or row-by-row.

Link copied to clipboard
fun sortVec(source: Tensor, sortedResult: Tensor?, indexResult: Tensor?)

Sort a scalar array.

Link copied to clipboard

Submit the pipeline for one run. Note: the method only submits the run as a task, and SpatialML framework will schedule the task based on its waitFor task, the GlobalTensor it will access, and the current computation resource availability.

Link copied to clipboard
fun switchCHWAndHWC(source: Tensor, result: Tensor)

Switch tensor content between a CHW and HWC format. A tensor of CHW format means it is a multi-dimensional tensor of 1 channel, 3 dimensions: CxHxW. A tensor of HWC format means it is a multi-dimensional tensor of C channels, 2 dimensions: HxW.

Link copied to clipboard
fun switchSceneVisibility(sceneEntity: Tensor, visible: Tensor)

Control the visibility of an already-loaded scene graph tensor.

Link copied to clipboard
fun updateSceneGraphProperty(sceneEntity: Tensor, entityPath: String, targetProperty: SceneGraphProperty, data: Tensor)

Update data of a specified component property in the scene graph, using the values from a tensor.

Link copied to clipboard
fun updateSceneGraphTextContent(sceneEntity: Tensor, entityPath: String, text: String)

Update data of text content of a text component in the scene graph using a text String.

Link copied to clipboard
fun updateSceneGraphTextHorizontalAlignment(sceneEntity: Tensor, entityPath: String, horizontalAlignment: Pipeline.TextHorizontalAlignment)

Update data of horizontal alignment of a text component in the scene graph using the alignment enum defined in TextHorizontalAlignment.

Link copied to clipboard
fun updateSceneGraphTextVerticalAlignment(sceneEntity: Tensor, entityPath: String, verticalAlignment: Pipeline.TextVerticalAlignment)

Update data of vertical alignment of a text component in the scene graph using the alignment enum defined in TextVerticalAlignment.

Link copied to clipboard
fun uvTo3DInCameraSpace(uv: Tensor, timestamp: Tensor, camMatrix: Tensor, leftImage: Tensor, rightImage: Tensor, point3Result: Tensor)

Using PICO's depth sensor and stereo view RGB images, estimate the 3D coordinates of 2D points on camera output.