CardDetector detector = new CardDetector(MainActivity.this); // 构造Detector
CardConfiguration config = new CardConfiguration();
config.setCardType(CardConfiguration.DRIVINGPERMIT);
detector.setCardConfiguration(config);
Frame frame = new Frame();
frame.setBitmap(bitmap);JSONObject jsonObject = detector.detect(frame, null);
Log.e(TAG, "doInBackground: total time=" + (System.currentTimeMillis() - time));
DrivingPermit drivingpermit = (DrivingPermit) detector.convertResult(jsonObject);
{
"resultCode": 0,
"common_text ": {
"address":"UAC3021181",
"Capacity":""
"Character":""
"EngineNO":
"Equipmentweight":""
"FileId":"320045256789",
"Inspectionrecord":""
"IssueDate": "20210126",
"Loadweight" ""
"Model":"五菱之光"
"Outlinesize":""
"Owner": "王元",
"PlateNO":"粤RPU005"
"RegisterDate": "19940101",
"Totalweight": ""
"Tractionweight":""
"Type":"小型普通客车",
"VIN":"UAC3021181"
"remark_1":"",
"remark_2":""
}
}
可以的,在detect()方法中会默认启动引擎,如果引擎已经启动则不会再次启动,开发者可以放心使用。
卡证OCR为端侧能力,在无网络连接的环境下仍可正常使用。
release()方法会卸载在NPU芯片中已经加载的模型,请在应用不再使用时及时调用release方法卸载模型,释放资源。