nativescript-dynamsoft-barcode-reader
Nativescript 动态库插件,用于 Dynamsoft Barcode Reader
npm i --save nativescript-dynamsoft-barcode-reader
- 版本:1.1.2
- GitHub:
- NPM: https://npmjs.net.cn/package/nativescript-dynamsoft-barcode-reader
- 下载量
- 昨天: 0
- 上周: 5
- 上个月: 16
nativescript-dynamsoft-barcode-reader
Nativescript 插件,用于 Dynamsoft Barcode Reader.
我们可以用它从摄像头帧或静态图像等来源读取条形码。
安装
npm install nativescript-dynamsoft-barcode-reader
使用
初始化
this.dbr = new BarcodeReader();
this.dbr.initLicense("DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ=="); //1-day public trial.
解码
-
从摄像头帧解码
let results = this.dbr.decodeFrame(this.dce.captureFrame()); //get a camera frame from Dynamsoft Camera Enhancer
-
使用 Dynamsoft Camera Enhancer 开始实时扫描。
//bind Dynamsoft Camera Enhancer to Dynamsoft Barcode Reader
this.dbr.setCameraEnhancer(this.dce.getCameraEnhancer());
//set the text result listener
this.dbr.setTextResultListener(function (textResults:TextResult[]) {
console.log(textResults);
})
//start scanning from the camera
this.dbr.startScanning();
您可以在 此处 申请试用许可证。
API
方法
initLicense(license:string,licenseListener?:LicenseListener):void;
initRuntimeSettingsWithString(template:string);
decodeFrame(frame:any):TextResult[];
decodeFrameAsync(frame:any):Promise<TextResult[]>;
decodeBitmap(bitmap:any):TextResult[];
decodeBase64(base64:string):TextResult[];
decodeFile(file:string):TextResult[];
setCameraEnhancer(dce:any):void;
startScanning():void;
stopScanning():void;
setTextResultListener(listener: TextResultListener);
接口
export interface TextResultListener{
(results:TextResult[]):void;
}
export interface LicenseListener{
(isSuccess:boolean,error:any):void;
}
export interface TextResult {
barcodeText:string;
barcodeFormat:string;
x1:number;
x2:number;
x3:number;
x4:number;
y1:number;
y2:number;
y3:number;
y4:number;
}
许可协议
Apache 许可协议第 2 版