当前位置: 首页 > news >正文

OcrLicenseVo

public static OcrLicenseVo parseOcrLicense(OcrResultVo item) {int[][][] dtPolyList = new int[9][2][2];for (int i = 0; i < item.getRecTexts().size(); i++) {String value = StringUtils.trimToEmpty(item.getRecTexts().get(i));if(StringUtils.anyContains(BREAK_NAME, value)){break;}if(StringUtils.isBlank(value) && StringUtils.anyContains(CONTINUE_NAME, value)){continue;}short idx;if(StringUtils.startsWith(value, "称")){idx = orgNameIndex;int[][] dtPoly = null;if(StringUtils.length(value) > 1){item.getRecTexts().set(i, StringUtils.substring(value, 1));dtPoly = item.getDtPolys().get(i-1);} else {dtPoly = item.getDtPolys().get(i);}dtPolyList[idx] = dtPoly;}else if(StringUtils.startsWith(value, "注册资本")){idx = capitalIndex;if(StringUtils.length(value) > 4){item.getRecTexts().set(i, StringUtils.substring(value, 4));}int[][] dtPoly = item.getDtPolys().get(i);dtPolyList[idx] = dtPoly;}else if(StringUtils.startsWith(value, "成立日期")){idx = establishDateIndex;int[][] dtPoly = item.getDtPolys().get(i);if(StringUtils.length(value) > 4){item.getRecTexts().set(i, StringUtils.substring(value, 4));}dtPolyList[idx] = dtPoly;} else if(StringUtils.startsWith(value, "营业期限")){idx = termIndex;int[][] dtPoly = item.getDtPolys().get(i);if(StringUtils.length(value) > 4){item.getRecTexts().set(i, StringUtils.substring(value, 4));}dtPolyList[idx] = dtPoly;} else if(StringUtils.startsWith(value, "法定代表人")){idx = legalPersonIndex;int[][] dtPoly = item.getDtPolys().get(i);if(StringUtils.length(value) > 5){item.getRecTexts().set(i, StringUtils.substring(value, 5));}dtPolyList[idx] = dtPoly;} else if(StringUtils.startsWith(value, "定代表人")){idx = legalPersonIndex;int[][] dtPoly = item.getDtPolys().get(i);if(StringUtils.length(value) > 4){item.getRecTexts().set(i, StringUtils.substring(value, 4));}dtPolyList[idx] = dtPoly;} else if(StringUtils.startsWith(value, "经营范围")){idx = scopeIndex;int[][] dtPoly = item.getDtPolys().get(i);if(StringUtils.length(value) > 4){item.getRecTexts().set(i, StringUtils.substring(value, 4));}dtPolyList[idx] = dtPoly;} else if(StringUtils.startsWith(value, "所")){idx = addressIndex;int[][] dtPoly = null;if(StringUtils.length(value) > 1){item.getRecTexts().set(i, StringUtils.substring(value, 1));dtPoly = item.getDtPolys().get(i-1);} else {dtPoly = item.getDtPolys().get(i);}dtPolyList[idx] = dtPoly;}else if(StringUtils.startsWith(value, "型")){idx = orgTypeIndex;int[][] dtPoly = null;if(StringUtils.length(value) > 1){item.getRecTexts().set(i, StringUtils.substring(value, 1));dtPoly = item.getDtPolys().get(i-1);} else {dtPoly = item.getDtPolys().get(i);}dtPolyList[idx] = dtPoly;} else {idx = getValueIndex(value);if(idx >= 0){int[][] dtPoly = item.getDtPolys().get(i);dtPolyList[idx] = dtPoly;}}}String[] licenseValues = new String[9];for (int i = 0; i < item.getRecTexts().size(); i++) {String value = StringUtils.trimToEmpty(item.getRecTexts().get(i));if(StringUtils.anyContains(BREAK_NAME, value)){break;}if(StringUtils.isBlank(value) && StringUtils.anyContains(CONTINUE_NAME, value)){continue;}if (LICENSE_PATTERN_SIMPLE.matcher(value).matches()) {licenseValues[creditCodeIndex] = value;log.info("scan value {} {} {}", i, 0, value);} else {int[][] currentPoly = item.getDtPolys().get(i);for (int index = 0; index < dtPolyList.length; index++) {int[][] dtPoly = dtPolyList[index];int hdiff = Math.abs(currentPoly[0][0] - dtPoly[0][0]);int vdiff = Math.abs(currentPoly[3][1] - dtPoly[3][1]);if(hdiff == 0 && vdiff == 0){log.info("scan name {} {} {}", i, index, value);break;}//看2.png 类和名(称}第0个坐标的横坐标太近,不是名称//看3.png 械和 住所第0个坐标的横坐标太远,不是地址if(Objects.nonNull(dtPoly) && hdiff <50 && vdiff <80){//index=0是营业执照,通过正则获取if(index == 0){continue;}licenseValues[index] = StringUtils.trimToEmpty(licenseValues[index]) + value;} else {log.info("skip {} {} {}", i, index, value);}}}}OcrLicenseVo ocrLicenseVo = new OcrLicenseVo();ocrLicenseVo.setCreditCode(licenseValues[creditCodeIndex]);ocrLicenseVo.setOrgName(licenseValues[orgNameIndex]);ocrLicenseVo.setCapital(licenseValues[capitalIndex]);ocrLicenseVo.setOrgType(licenseValues[orgTypeIndex]);ocrLicenseVo.setEstablishDate(licenseValues[establishDateIndex]);ocrLicenseVo.setLegalPerson(licenseValues[legalPersonIndex]);ocrLicenseVo.setAddress(licenseValues[addressIndex]);ocrLicenseVo.setScope(licenseValues[scopeIndex]);ocrLicenseVo.setTerm(licenseValues[termIndex]);return ocrLicenseVo;}

 

http://www.jsqmd.com/news/4062/

相关文章:

  • 实用指南:C#上位机软件:1.7 熟悉VS并开启你的第一个C#程序
  • 界面控件DevExpress WinForms v25.1 - AI聊天控件功能持续增强
  • K8S Deployment 学习
  • 全面掌握 Py2neo 与 Neo4j:从容器化部署到高级应用实战 - 详解
  • 原型
  • 集训队作业1——qoj#11722
  • US$59 EGS ISN Authorization for CGDI Prog BMW MSV80 Key Programmer
  • 如何设置将浏览器网页临时禁用网页mathjax渲染直接查看latex编译前的文本
  • 《IDEA 2025破解 长效使用指南:2099 年有效期配置实战之JetBrains全家桶有效》​
  • 软件开发公司如何利用大数据可视化设计提升决策效率
  • 基于菲涅尔积分的角锥喇叭方向图计算
  • Flask的ORM工具SQLAlchemy
  • 使用 Rust 和 Tesseract OCR 实现英文数字验证码识别
  • 构建复合AI系统以实现可扩展工作流
  • Python HTTPS 爬虫实战,requests aiohttp Selenium 抓取技巧、HTTPS 问题与抓包调试(python https爬虫、反爬、抓包、证书处理)
  • 深入解析:基于开源AI大模型AI智能名片S2B2C商城小程序的产地优势产品营销策略研究
  • GreatSQL 优化技巧:最值子查询与窗口函数相互转换
  • Windows Time 时间同步时出错
  • 鸿蒙自定义弹出框响应式更新数据
  • CCS开发环境和TMS320系列DSP实现IP-IQ谐波与无功电流检测
  • 深入解析:Python数据分析:求矩阵的秩。啥是矩阵秩?听故事学线代并用Python实现,娘来太容易学会了!
  • 多机动模型PHD滤波算法
  • Navicat17无限试用重置14天
  • 基于Electron的Web打印解决方案:web-print-pdf技术分享
  • CF455D Serega and Fun
  • 实验任务1
  • 实验任务
  • 61.【.NET8 实战--孢子记账--从单体到微服务--转向微服务】--新增功能--提取金额 - 实践
  • 使用 Ansible 部署 Elasticsearch 集群
  • 免费无广告!这款开源工具让文件转换像复制粘贴一样简单!