Skip to content

QRCodeDetector

objdetectclassOpenCV 5.0.0
import { QRCodeDetector } 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 GraphicalCodeDetector.

QR code detector.

Constructors and members

static new

Create an owned QRCodeDetector object. Release native handles with using or delete().

new(): QRCodeDetector;
Returns

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

setEpsX

sets the epsilon used during the horizontal scan of QR code stop marker detection.

setEpsX(epsX: number): QRCodeDetector;
epsX

Epsilon neighborhood, which allows you to determine the horizontal pattern of the scheme 1:1:3:1:1 according to QR code standard.

Returns

The QRCodeDetector result.

setEpsY

sets the epsilon used during the vertical scan of QR code stop marker detection.

setEpsY(epsY: number): QRCodeDetector;
epsY

Epsilon neighborhood, which allows you to determine the vertical pattern of the scheme 1:1:3:1:1 according to QR code standard.

Returns

The QRCodeDetector result.

setUseAlignmentMarkers

use markers to improve the position of the corners of the QR code

alignmentMarkers using by default

setUseAlignmentMarkers(useAlignmentMarkers: boolean): QRCodeDetector;
useAlignmentMarkers

use alignment markers argument (boolean).

Returns

The QRCodeDetector result.

decodeCurved

Decodes QR code on a curved surface in image once it's found by the detect() method.

 Returns UTF8-encoded output string or empty string if the code cannot be decoded.
decodeCurved(img: Mat, points: Mat, straight_qrcode: Mat): string;
2 available overloads
decodeCurved(img: Mat, points: Mat): string;
decodeCurved(img: Mat, points: Mat, straight_qrcode: Mat): string;
img

grayscale or color (BGR) image containing QR code.

points

Quadrangle vertices found by detect() method (or some other algorithm).

straight_qrcode

Output destination, filled by the native operation. The optional output image containing rectified and binarized QR code

Returns

The string result.

detectAndDecodeCurved

Both detects and decodes QR code on a curved surface

detectAndDecodeCurved(img: Mat, points: Mat, straight_qrcode: Mat): string;
3 available overloads
detectAndDecodeCurved(img: Mat): string;
detectAndDecodeCurved(img: Mat, points: Mat): string;
detectAndDecodeCurved(img: Mat, points: Mat, straight_qrcode: Mat): string;
img

grayscale or color (BGR) image containing QR code.

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.

straight_qrcode

Output destination, filled by the native operation. The optional output image containing rectified and binarized QR code

Returns

The string result.

getEncoding

Returns a kind of encoding for the decoded info from the latest decode or detectAndDecode call

getEncoding(codeIdx: number): number;
2 available overloads
getEncoding(): number;
getEncoding(codeIdx: number): number;
codeIdx

an index of the previously decoded QR code. When decode or detectAndDecode is used, valid value is zero. For decodeMulti or detectAndDecodeMulti use indices corresponding to the output order.

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.