barcode_BarcodeDetector
import { barcode_BarcodeDetector } 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.
barcode barcode detector value in the OpenCV API.
Constructors and members
static new
Initialize the BarcodeDetector with a Super Resolution model.
Loads a Super Resolution DNN model in ONNX format, used to upscale small/low-quality barcode crops before decoding for better quality.
Note: Caffe models (sr.prototxt / sr.caffemodel) are no longer supported; convert
the model to ONNX (a converted sr.onnx is available from
https://github.com/WeChatCV/opencv_3rdparty/tree/wechat_qrcode).
new(super_resolution_model_path: EmbindString): barcode_BarcodeDetector;2 available overloads
new(): barcode_BarcodeDetector;new(super_resolution_model_path: EmbindString): barcode_BarcodeDetector;super_resolution_model_pathpath to a single-file ONNX Super Resolution model.
The barcode_BarcodeDetector 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;The this result.
decodeWithType
Decodes barcode in image once it's found by the detect() method.
decodeWithType(img: Mat, points: Mat, decoded_info: StringVector, decoded_type: StringVector): boolean;imggrayscale or color (BGR) image containing bar code.
pointsvector of rotated rectangle vertices found by detect() method (or some other algorithm). For N detected barcodes, the dimensions of this array should be [N][4]. Order of four points in vector<Point2f> is bottomLeft, topLeft, topRight, bottomRight.
decoded_infoOutput destination, filled by the native operation. UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
decoded_typeOutput destination, filled by the native operation. vector strings, specifies the type of these barcodes
true if at least one valid barcode have been found
detectAndDecodeWithType
Both detects and decodes barcode
detectAndDecodeWithType(img: Mat, decoded_info: StringVector, decoded_type: StringVector, points: Mat): boolean;2 available overloads
detectAndDecodeWithType(img: Mat, decoded_info: StringVector, decoded_type: StringVector): boolean;detectAndDecodeWithType(img: Mat, decoded_info: StringVector, decoded_type: StringVector, points: Mat): boolean;imggrayscale or color (BGR) image containing barcode.
decoded_infoOutput destination, filled by the native operation. UTF8-encoded output vector of string(s) or empty vector of string if the codes cannot be decoded.
decoded_typeOutput destination, filled by the native operation. vector of strings, specifies the type of these barcodes
pointsOutput destination, filled by the native operation. optional output vector of vertices of the found barcode rectangle. Will be empty if not found.
true if at least one valid barcode have been found
getDownsamplingThreshold
Get detector downsampling threshold.
getDownsamplingThreshold(): number;detector downsampling threshold
setDownsamplingThreshold
Set detector downsampling threshold.
By default, the detect method resizes the input image to this limit if the smallest image size is is greater than the threshold. Increasing this value can improve detection accuracy and the number of results at the expense of performance. Correlates with detector scales. Setting this to a large value will disable downsampling.
See: setDetectorScales
setDownsamplingThreshold(thresh: number): barcode_BarcodeDetector;threshdownsampling limit to apply (default 512)
The barcode_BarcodeDetector result.
getDetectorScales
Returns detector box filter sizes.
getDetectorScales(sizes: FloatVector): void;sizesOutput destination, filled by the native operation. output parameter for returning the sizes.
setDetectorScales
Set detector box filter sizes.
Adjusts the value and the number of box filters used in the detect step. The filter sizes directly correlate with the expected line widths for a barcode. Corresponds to expected barcode distance. If the downsampling limit is increased, filter sizes need to be adjusted in an inversely proportional way.
setDetectorScales(sizes: FloatVector): barcode_BarcodeDetector;sizesbox filter sizes, relative to minimum dimension of the image (default [0.01, 0.03, 0.06, 0.08])
The barcode_BarcodeDetector result.
getGradientThreshold
Get detector gradient magnitude threshold.
getGradientThreshold(): number;detector gradient magnitude threshold.
setGradientThreshold
Set detector gradient magnitude threshold.
Sets the coherence threshold for detected bounding boxes. Increasing this value will generate a closer fitted bounding box width and can reduce false-positives. Values between 16 and 1024 generally work, while too high of a value will remove valid detections.
setGradientThreshold(thresh: number): barcode_BarcodeDetector;threshgradient magnitude threshold (default 64).
The barcode_BarcodeDetector 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.