CardDetector detector = new CardDetector(TestDriverLicense.this); // 构造Detector
CardConfiguration config = new CardConfiguration();
config.setCardType(CardConfiguration.DRIVERLICENSE);
detector.setCardConfiguration(config);
Frame frame = new Frame();
frame.setBitmap(bitmap);JSONObject jsonObject = detector.detect(frame, null);
String convertedJson = jsonObject.toString().replaceAll("\\\\", "");
Log.e(TAG, "doInBackground: total time=" + (System.currentTimeMillis() - time));
DriverLicense passport = (DriverLicense) detector.convertResult(jsonObject);
1. 驾驶证主页
{
"resultCode": 0,
"common_text ": {
"address": "",
"birthDate": "19830415",
"carClass": "C1",
"id": "230688192006181132",
"issueDate": "",
"page": "1",
"name": "王元",
"nation": "",
"sex": "男",
"startDate": "19940101",
"validDate": "20210126",
"validPeriod": "6年",
"remark_1": "",
"remark_2": ""
}
}2. 驾驶证副页
{
"resultCode": 0,
"common_text ": {
"fileId": "320045256789",
"page": "2",
"name": "王元",
"record": "",
"remark_1": "",
"remark_2": ""
}
}
可以的,在detect()方法中会默认启动引擎,如果引擎已经启动则不会再次启动,开发者可以放心使用。
卡证OCR为端侧能力,在无网络连接的环境下仍可正常使用。
release()方法会卸载在NPU芯片中已经加载的模型,请在应用不再使用时及时调用release方法卸载模型,释放资源。