Skip to content

structured_light_GrayCodePattern

structured_lightclassOpenCV 5.0.0
import { structured_light_GrayCodePattern } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits structured_light_StructuredLightPattern.

Class implementing the Gray-code pattern, based on [UNDERWORLD].

The generation of the pattern images is performed with Gray encoding using the traditional white and black colors.

The information about the two image axes x, y is encoded separately into two different pattern sequences. A projector P with resolution (P_res_x, P_res_y) will result in Ncols = log 2 (P_res_x) encoded pattern images representing the columns, and in Nrows = log 2 (P_res_y) encoded pattern images representing the rows. For example a projector with resolution 1024x768 will result in Ncols = 10 and Nrows = 10. However, the generated pattern sequence consists of both regular color and color-inverted images: inverted pattern images are images with the same structure as the original but with inverted colors. This provides an effective method for easily determining the intensity value of each pixel when it is lit (highest value) and when it is not lit (lowest value). So for a a projector with resolution 1024x768, the number of pattern images will be Ncols * 2 + Nrows * 2 = 40.

Constructors and members

static create

structured_light_GrayCodePattern.create: Constructor

create(width: number, height: number): structured_light_GrayCodePattern | null;
width

width argument (number).

height

height argument (number).

Returns

The structured_light_GrayCodePattern | null result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

getNumberOfPatternImages

Get the number of pattern images needed for the graycode pattern.

getNumberOfPatternImages(): number;
Returns

The number of pattern images needed for the graycode pattern.

setWhiteThreshold

Sets the value for white threshold, needed for decoding.

White threshold is a number between 0-255 that represents the minimum brightness difference required for valid pixels, between the graycode pattern and its inverse images; used in getProjPixel method.

setWhiteThreshold(value: number): void;
value

The desired white threshold value.

setBlackThreshold

Sets the value for black threshold, needed for decoding (shadowsmasks computation).

Black threshold is a number between 0-255 that represents the minimum brightness difference required for valid pixels, between the fully illuminated (white) and the not illuminated images (black); used in computeShadowMasks method.

setBlackThreshold(value: number): void;
value

The desired black threshold value.

getImagesForShadowMasks

Generates the all-black and all-white images needed for shadowMasks computation.

To identify shadow regions, the regions of two images where the pixels are not lit by projector's light and thus where there is not coded information, the 3DUNDERWORLD algorithm computes a shadow mask for the two cameras views, starting from a white and a black images captured by each camera. This method generates these two additional images to project.

getImagesForShadowMasks(blackImage: Mat, whiteImage: Mat): void;
blackImage

Input/output value, modified by the native operation. The generated all-black CV_8U image, at projector's resolution.

whiteImage

Input/output value, modified by the native operation. The generated all-white CV_8U image, at projector's resolution.

getProjPixel

For a (x,y) pixel of a camera returns the corresponding projector pixel.

The function decodes each pixel in the pattern images acquired by a camera into their corresponding decimal numbers representing the projector's column and row, providing a mapping between camera's and projector's pixel.

getProjPixel(patternImages: MatVector, x: number, y: number): structured_light_GrayCodePattern_getProjPixelResult;
patternImages

The pattern images acquired by the camera, stored in a grayscale vector < Mat >.

x

x coordinate of the image pixel.

y

y coordinate of the image pixel.

Returns

The structured_light_GrayCodePattern_getProjPixelResult result. Scalar output parameters are returned as named fields in this object. Release returned native handles with using or delete(), including handles nested in results.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.