资源简介
Java使用Tess4J 进行图片文字识别

代码片段和文件信息
/**
* JDeskew
*/
package com.recognition.software.jdeskew;
import java.awt.image.BufferedImage;
public class ImageDeskew {
/**
* Representation of a line in the image.
*/
public class HoughLine {
// count of points in the line
public int count = 0;
// index in matrix.
public int index = 0;
// the line is represented as all x y that solve y * cos(alpha) - x *
// sin(alpha) = d
public double alpha;
public double d;
}
// the source image
private BufferedImage cImage;
// the range of angles to search for lines
private double cAlphaStart = -20;
private double cAlphaStep = 0.2;
private int cSteps = 40 * 5;
// pre-calculation of sin and cos
private double[] cSinA;
private double[] cCosA;
// range of d
private double cDMin;
private double cDStep = 1.0;
private int cDCount;
// count of points that fit in a line
private int[] cHMatrix;
// constructor
public ImageDeskew(BufferedImage image) {
this.cImage = image;
}
// calculate the skew angle of the image cImage
public double getSkewAngle() {
ImageDeskew.HoughLine[] hl;
double sum = 0.0;
int count = 0;
// perform Hough Transformation
calc();
// top 20 of the detected lines in the image
hl = getTop(20);
if (hl.length >= 20) {
// average angle of the lines
for (int i = 0; i < 19; i++) {
sum += hl[i].alpha;
count++;
}
return (sum / count);
} else {
return 0.0d;
}
}
// calculate the count lines in the image with most points
private ImageDeskew.HoughLine[] getTop(int count) {
ImageDeskew.HoughLine[] hl = new ImageDeskew.HoughLine[count];
for (int i = 0; i < count; i++) {
hl[i] = new ImageDeskew.HoughLine();
}
ImageDeskew.HoughLine tmp;
for (int i = 0; i < (this.cHMatrix.length - 1); i++) {
if (this.cHMatrix[i] > hl[count - 1].count) {
hl[count - 1].count = this.cHMatrix[i];
hl[count - 1].index = i;
int j = count - 1;
while ((j > 0) && (hl[j].count > hl[j - 1].count)) {
tmp = hl[j];
hl[j] = hl[j - 1];
hl[j - 1] = tmp;
j--;
}
}
}
int alphaIndex;
int dIndex;
for (int i = 0; i < count; i++) {
dIndex = hl[i].index / cSteps; // integer division no
// remainder
alphaIndex = hl[i].index - dIndex * cSteps;
hl[i].alpha = getAlpha(alphaIndex);
hl[i].d = dIndex + cDMin;
}
re
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-09-22 11:07 Tess4J\
目录 0 2013-09-22 11:07 Tess4J\dist\
目录 0 2013-09-21 08:34 Tess4J\lib\
目录 0 2013-09-21 08:35 Tess4J\nbproject\
目录 0 2013-02-28 22:17 Tess4J\nbproject\private\
目录 0 2013-02-28 22:17 Tess4J\src\
目录 0 2013-02-28 22:17 Tess4J\src\com\
目录 0 2013-02-28 22:17 Tess4J\src\com\recognition\
目录 0 2013-02-28 22:17 Tess4J\src\com\recognition\software\
目录 0 2013-02-28 22:17 Tess4J\src\com\recognition\software\jdeskew\
目录 0 2013-02-28 22:17 Tess4J\src\net\
目录 0 2013-09-21 12:06 Tess4J\src\net\sourceforge\
目录 0 2013-09-21 12:06 Tess4J\src\net\sourceforge\tess4j\
目录 0 2013-09-21 12:06 Tess4J\src\net\sourceforge\vietocr\
目录 0 2013-09-21 12:12 Tess4J\tessdata\
目录 0 2013-02-28 22:17 Tess4J\tessdata\configs\
目录 0 2013-02-28 22:17 Tess4J\test\
目录 0 2013-02-28 22:17 Tess4J\test\net\
目录 0 2013-09-21 08:52 Tess4J\test\net\sourceforge\
目录 0 2013-09-21 08:52 Tess4J\test\net\sourceforge\tess4j\
目录 0 2013-09-21 08:52 Tess4J\test\net\sourceforge\tess4j\utiltities\
文件 5153 2013-08-31 10:01 Tess4J\build.xm
文件 1322 2013-09-22 11:07 Tess4J\dist\README.TXT
文件 69037 2013-09-22 11:07 Tess4J\dist\tess4j.jar
文件 102464 2013-02-28 22:17 Tess4J\eurotext.bmp
文件 20359 2013-02-28 22:17 Tess4J\eurotext.gif
文件 13065 2013-02-28 22:17 Tess4J\eurotext.pdf
文件 14854 2013-02-28 22:17 Tess4J\eurotext.png
文件 102598 2013-02-28 22:17 Tess4J\eurotext.tif
文件 204383 2013-02-28 22:17 Tess4J\eurotext_deskew.png
文件 31679 2013-02-28 22:17 Tess4J\lib\ghost4j-0.3.1.jar
............此处省略35个文件信息
相关资源
- java-图片识别 图片比较
- 超级好的纯jsp写的聊天室
- java图片轮播代码 可控制
- android图片压缩工具类分享
- Vue项目实现手机端上传图片,使用于
- Android图片上传头像裁切+原图原样
- 基于JavaWeb的美食图片分享网站.zip
- JAVA开发的中国象棋游戏包括源码和需
- 初学JAVA时编写的rpg文字游戏
- JAVA飞机大战 ,附所有图片以及实验报
- im4java-ImageMagick图片压缩处理
- Java中使用 FreeMarker 生成pdf盖章合同文
- ajax上传图片
- JAVA连连看包括源码。图片等
- Android 完美实现图片圆角和圆形 bug修
- java 生成二维码 且中间 带图片(log
- 点九图片制作工具
- 基于JAVA技术爬虫爬网站图片设计与实
- emoji表情png图片
- Android-EasyShow3D一个基于OpenGLES的简单易
- Java 界面漂亮的打字软件源码.rar
- 科大讯飞语音转为文字java开发
- Java 8 简明教程 Java 8 Tutorial中文版文字
- 使用Java开发的OCR程序 根据图像识别转
- android拼图游戏完整源码,图片剪切,
- webView选择图片并上传
- creator实现调用android相机相册,并实现
- Android旋转专辑图片—仿留声机效果
- eclipse --- Android拍照,相册选择图片以
- JAVA图片浏览器270361
评论
共有 条评论