android {
defaultConfig {
....
ndk {
abiFilters 'armeabi' //自行选择添加
}
}
}
dependencies {
compile 'com.rmtheis:tess-two:8.0.0'
}
public String detectText(Bitmap bitmap) {
TessBaseAPI tessBaseAPI = new TessBaseAPI();
String path = ""; //训练数据路径
tessBaseAPI.setDebug(true);
tessBaseAPI.init(path, "eng"); //eng为识别语言
tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); // 识别白名单
tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!@#$%^&*()_+=-[]}{;:'\"\\|~`,./<>?"); // 识别黑名单
tessBaseAPI.setPageSegMode(TessBaseAPI.PageSegMode.PSM_AUTO_OSD);//设置识别模式
tessBaseAPI.setImage(bitmap); //设置需要识别图片的bitmap
String inspection = tessBaseAPI.getHOCRText(0);
tessBaseAPI.end();
return inspection ;
}
Result rawResult = null;
MultiFormatReader mMultiFormatReade = new MultiFormatReader();
try {
PlanarYUVLuminanceSource source =
new PlanarYUVLuminanceSource(```, false);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
rawResult = mMultiFormatReader.decode(bitmap, mHints);
} catch (ReaderException ignored) {
} finally {
mMultiFormatReader.reset();
}
public static String getTelNum(String sParam){
if(TextUtils.isEmpty(sParam)){
return "";
}
Pattern pattern = Pattern.compile("(1|861)(3|5|7|8)\\d{9}$*");
Matcher matcher = pattern.matcher(sParam);
StringBuilder bf = new StringBuilder();
while (matcher.find()) {
bf.append(matcher.group()).append(",");
}
int len = bf.length();
if (len > 0) {
bf.deleteCharAt(len - 1);
}
return bf.toString();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有