当前位置: 首页 > 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.gsyq.cn/news/12089.html

相关文章:

  • 全面掌握 Py2neo 与 Neo4j:从容器化部署到高级应用实战 - 详解
  • 原型
  • 如何设置将浏览器网页临时禁用网页mathjax渲染直接查看latex编译前的文本
  • 软件开发公司如何利用大数据可视化设计提升决策效率
  • 使用 Rust 和 Tesseract OCR 实现英文数字验证码识别
  • Python HTTPS 爬虫实战,requests aiohttp Selenium 抓取技巧、HTTPS 问题与抓包调试(python https爬虫、反爬、抓包、证书处理)
  • 深入解析:基于开源AI大模型AI智能名片S2B2C商城小程序的产地优势产品营销策略研究
  • GreatSQL 优化技巧:最值子查询与窗口函数相互转换
  • Windows Time 时间同步时出错
  • CCS开发环境和TMS320系列DSP实现IP-IQ谐波与无功电流检测
  • 深入解析:Python数据分析:求矩阵的秩。啥是矩阵秩?听故事学线代并用Python实现,娘来太容易学会了!
  • Navicat17无限试用重置14天
  • 基于Electron的Web打印解决方案:web-print-pdf技术分享
  • CF455D Serega and Fun
  • 实验任务
  • React 基础核心概念(8 个)——从入门到能写业务组件(上)| 葡萄城技术团队
  • 实用指南:轻松玩转Swagger API文档神器
  • 为什么人工智能选择Python?深入解析AI界的胶水语言
  • 1 day(20250925) - when
  • 【重要】什么是 PEP 8 规范
  • 实用指南:华为坤灵:点燃中小企业智能化的星火
  • Windows时间同步列表注册表授时时间服务器
  • Mac 安装PDF2zh
  • 2025Unity必备知识——GUI(完整详细) - 指南
  • 读人形机器人23政府的角色
  • Python 在人工智能与机器学习中的地位与实践
  • 十八岁前开始远征
  • 设置vscode的默认字符编码
  • Natural Language Processing
  • Python 在自动化与运维中的价值与实践