CardDetector detector = new CardDetector(MainActivity.this); // 构造Detector
CardConfiguration config = new CardConfiguration();
config.setCardType(CardConfiguration.IDCard);
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));
IDCard card = (IDCard) detector.convertResult(jsonObject);
{
"resultCode": 0,
"common_text": "{"
address ":"
上海市南京路5号 ","
birthday ":"
1990 年1月1日 ","
gender ":"
男 ","
id ":"
300010199001010011 ","
name ":"
刘小华 ","
nation ":"
汉 ","
type ":"
Photo "}"
}{
"resultCode": 0,
"common_text": "{"
expiration ":"
2017,
12.22 - 2037.12 .22 ","
organization ":"
上海市公安局静安分局 ","
type ":"
Emblem "}"
}
可以的,在detect()方法中会默认启动引擎,如果引擎已经启动则不会再次启动,开发者可以放心使用。
身份证OCR为端侧能力,在无网络连接的环境下仍可正常使用。