Skip to content

wechat_qrcode_WeChatQRCode

wechat_qrcodeclassOpenCV 5.0.0
import { wechat_qrcode_WeChatQRCode } 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.

WeChat QRCode includes two CNN-based models: A object detection model and a super resolution model. Object detection model is applied to detect QRCode with the bounding box. super resolution model is applied to zoom in QRCode when it is small.

Constructors and members

static new

Initialize the WeChatQRCode. It includes two CNN-based models in ONNX format: a detector model and a super resolution model.

new(detector_model_path: EmbindString, super_resolution_model_path: EmbindString): wechat_qrcode_WeChatQRCode;
3 available overloads
new(): wechat_qrcode_WeChatQRCode;
new(detector_model_path: EmbindString): wechat_qrcode_WeChatQRCode;
new(detector_model_path: EmbindString, super_resolution_model_path: EmbindString): wechat_qrcode_WeChatQRCode;
detector_model_path

onnx model file path for the detector

super_resolution_model_path

onnx model file path for the super resolution model

Returns

The wechat_qrcode_WeChatQRCode 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.

detectAndDecode

Both detects and decodes QR code. To simplify the usage, there is a only API: detectAndDecode

detectAndDecode(img: Mat, points: MatVector): StringVector;
2 available overloads
detectAndDecode(img: Mat): StringVector;
detectAndDecode(img: Mat, points: MatVector): StringVector;
img

supports grayscale or color (BGR) image.

points

Output destination, filled by the native operation. optional output array of vertices of the found QR code quadrangle. Will be empty if not found.

Returns

list of decoded string. Release returned native handles with using or delete(), including handles nested in results.

setScaleFactor

set scale factor QR code detector use neural network to detect QR. Before running the neural network, the input image is pre-processed by scaling. By default, the input image is scaled to an image with an area of 160000 pixels. The scale factor allows to use custom scale the input image: width = scaleFactorwidth height = scaleFactorwidth

scaleFactor valuse must be > 0 and <= 1, otherwise the scaleFactor value is set to -1 and use default scaled to an image with an area of 160000 pixels.

setScaleFactor(_scalingFactor: number): void;
_scalingFactor

scaling factor argument (number).

getScaleFactor

Read the scale factor.

set scale factor QR code detector use neural network to detect QR. Before running the neural network, the input image is pre-processed by scaling. By default, the input image is scaled to an image with an area of 160000 pixels. The scale factor allows to use custom scale the input image: width = scaleFactorwidth height = scaleFactorwidth

scaleFactor valuse must be > 0 and <= 1, otherwise the scaleFactor value is set to -1 and use default scaled to an image with an area of 160000 pixels.

getScaleFactor(): number;
Returns

The number result.

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.