package servlet;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import util.FileUtil;
import util.OCRUtil;
import com.jspsmart.upload.File;
import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;
public class OCRServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setCharacterEncoding("gbk");
SmartUpload upload = new SmartUpload();
// JspFactory sf = JspFactory.getDefaultFactory();
// upload.initialize(sf.getPageContext(this, request, response, null, false, JspWriter.DEFAULT_BUFFER, true));
ServletConfig sc = this.getServletConfig();
upload.initialize(sc, request, response);
File file = null;
long size = 5*1024*1024;
upload.setAllowedFilesList("gif,jpg,bmp,png");
upload.setMaxFileSize(size);
upload.setCharset("GBK");
try {
upload.upload();
file = upload.getFiles().getFile(0);
String userPath = "upload\\"+request.getRemoteAddr().replaceAll("\\.", "")+"\\";
String svpath = userPath+file.getFileName();
if(!file.isMissing()){
String realPath = request.getRealPath("/");
FileUtil.creatPath(realPath+userPath);
file.saveAs(svpath,SmartUpload.SAVE_VIRTUAL);
try {
OCRUtil.runOCR(realPath, realPath+svpath, realPath+userPath+"ocr",true);
request.setAttribute("txt", FileUtil.read(realPath+userPath+"ocr.txt").trim());
request.getRequestDispatcher("/index.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
FileUtil.delete(realPath+userPath);
}
} catch (SmartUploadException e) {
e.printStackTrace();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
OCR web端 java
共63个文件
exe:10个
class:3个
java:3个
2星 需积分: 50 16 下载量 42 浏览量
2018-01-31
17:59:30
上传
评论
收藏 29.18MB RAR 举报
温馨提示
做了个web版的OCR,用的是Tesseract-OCR。。。java 也可以
资源推荐
资源详情
资源评论
收起资源包目录
OCROnline.rar (63个子文件)
OCROnline
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.wst.common.component 465B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 493B
org.eclipse.jdt.core.prefs 395B
src
servlet
OCRServlet.java 2KB
util
OCRUtil.java 376B
FileUtil.java 1KB
.project 2KB
WebRoot
upload
META-INF
MANIFEST.MF 36B
WEB-INF
web.xml 664B
classes
servlet
OCRServlet.class 3KB
util
FileUtil.class 2KB
OCRUtil.class 1KB
lib
smartupload.jar 15KB
index.jsp 1KB
Tesseract-OCR
tessdata
eng.cube.word-freq 2.33MB
eng.tesseract_cube.nn 996B
chi_sim.traineddata 38.12MB
tessconfigs
matdemo 243B
batch.nochop 37B
msdemo 402B
batch 50B
nobatch 1B
segdemo 329B
eng.traineddata 20.86MB
eng.cube.lm_ 181B
eng.cube.fold 38B
configs
hocr 22B
api_config 26B
quiet 21B
unlv 46B
kannada 101B
rebox 65B
logfile 25B
inter 59B
ambigs.train 146B
linebox 70B
digits 37B
makebox 26B
bigram 129B
box.train 355B
strokewidth 377B
box.train.stderr 376B
eng.cube.lm 181B
eng.cube.params 254B
eng.cube.size 12.42MB
eng.cube.nn 837KB
eng.cube.bigrams 168KB
shapeclustering.exe 857KB
mftraining.exe 930KB
dawg2wordlist.exe 579KB
tesseract.exe 2.24MB
ambiguous_words.exe 1.04MB
combine_tessdata.exe 567KB
classifier_tester.exe 1.25MB
unicharset_extractor.exe 572KB
java
ScrollView.jar 25KB
wordlist2dawg.exe 661KB
cntraining.exe 602KB
.mymetadata 300B
.classpath 529B
共 63 条
- 1
资源评论
- sunshine09_192019-05-08你们下载程序复制来复制去,然后再上传有意思吗? 改过一个字吗?
无心1314
- 粉丝: 42
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功