Skip to main content

XR8.CameraPixelArray.pipelineModule()

XR8.CameraPixelArray.pipelineModule({ luminance, maxDimension, width, height })

Description

A pipeline module that provides the camera texture as an array of RGBA or grayscale pixel values that can be used for CPU image processing.

Parameters

ParameterDefaultDescription
luminance [Optional]falseIf true, output grayscale instead of RGBA
maxDimension: [Optional]The size in pixels of the longest dimension of the output image. The shorter dimension will be scaled relative to the size of the camera input so that the image is resized without cropping or distortion.
width [Optional]The width of the camera feed texture.Width of the output image. Ignored if maxDimension is specified.
height [Optional]The height of the camera feed texture.Height of the output image. Ignored if maxDimension is specified.

Returns

Return value is an object made available to onProcessCpu and onUpdate as:

processGpuResult.camerapixelarray: {rows, cols, rowBytes, pixels}

PropertyDescription
rowsHeight in pixels of the output image.
colsWidth in pixels of the output image.
rowBytesNumber of bytes per row of the output image.
pixelsA UInt8Array of pixel data.
srcTexA texture containing the source image for the returned pixels.

Example

XR8.addCameraPipelineModule(XR8.CameraPixelArray.pipelineModule({ luminance: true }))
XR8.addCameraPipelineModule({
name: 'mycamerapipelinemodule',
onProcessCpu: ({ processGpuResult }) => {
const { camerapixelarray } = processGpuResult
if (!camerapixelarray || !camerapixelarray.pixels) {
return
}
const { rows, cols, rowBytes, pixels } = camerapixelarray

...
},