表格化构建系统-加入新的系统功能

发布时间 2023-04-08 18:45:22作者: 冰稀饭Aurora

要实现的功能

1.图片识别表格化重建

2.保存识别记录,可以查看自己的记录

3.分析记录并统计总结

4.能够将所有的记录形成一个完整的个人总结性表格

 

 部分代码:

package org.example;//import com.sun.media.sound.InvalidFormatException;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws InvalidFormatException, IOException, TesseractException {
        ITesseract instance = new Tesseract();
        instance.setDatapath("src/main/resources/tessdata");
    instance.setLanguage("chi_sim"); String result = instance.doOCR(new File("src/main/resources/image.png")); String[] lines = result.split("\r?\n"); Workbook workbook = WorkbookFactory.create(new File("src/main/resources/table.xlsx")); Sheet sheet = workbook.getSheetAt(0); int rowCount = 0; for (String line : lines) { Row row = sheet.createRow(rowCount++); int columnCount = 0; for (String word : line.split("\s+")) { Cell cell = row.createCell(columnCount++); cell.setCellValue(word); } } File file = new File("src/main/resources/table_from_image.xlsx"); workbook.write(new FileOutputStream(file)); workbook.close(); } }
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>菜鸟教程</title>
    <link rel="stylesheet" href="css/side.css">

</head>
<body>

<div class="sidenav">
    <a href="http://localhost:8080/imageExcel_war_exploded/A1.html">关于我们</a>
    <a href="http://localhost:8080/imageExcel_war_exploded/A2.html">数据统计</a>
    <a href="http://localhost:8080/imageExcel_war_exploded/A3.html">我的记录</a>
    <a href="http://localhost:8080/imageExcel_war_exploded/A4.html">图片转化</a>
</div>

<div id="tabs-1" style="display: block">
    <form action="SubwayLine" >
        <table style="border-width: 0; width: 100%">
            <tr>

                <table border="1" style="border-left-color:     #B0C4DE; border-bottom-color:     #B0C4DE; width: 100%;border-top-style: solid; border-top-color:     #B0C4DE; border-right-style: solid; border-left-style: solid; height: 250px; border-right-color:     #B0C4DE; border-bottom-style: hidden">
                    <tr align="center"><td align="center" colspan="2">石家庄铁道大学北京地铁线路查询</td></tr>
                    <tr><td  style="width: 30%" align="center">线路名称:</td><td style="width: 70%" align="center"> <select name="line" style="height:40px;width:300px;">
                        <option value="1号线">1号线</option>
                        <option value="2号线">2号线</option>
                        <option value="4号线">4号线</option>
                    </select></td></tr>
                    <tr>
                        <td style="width: 50%" align="center" colspan="2"><input type="submit" style="height:40px;width:300px;" value="查询"/></td>
                    </tr>

                </table>
            </tr>
        </table>
    </form>
</div>

<hr />
<div style="text-align: center; width: 100%; font-size: 12px; color: #333;">&copy;版权所有:石家庄铁道大学信息科学与技术学院</div>

</body>
</html>