资源简介
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个文件信息
相关资源
- SpringMVC上传图片文件到 阿里云
- android安卓通过url获取网络图片并显示
- 解决react-native 的 webview 组件不支持
- android 拼图游戏可从手机选择一张图片
- android摇一摇随机变图片
- Android单点触控技术,对图片进行平移
- Android 使用开源库StickyGridHeaders来实现
- Android 使用ContentProvider扫描手机中的图
- Androidstudio写的异步加载网络图片
- Android上传图片
- Android-CameraView是一个可以轻松捕捉图
- 百度文字SDK识别DEMO-Eclipse版本
- Android 图片转视频
- JavaWeb入门经典-共享代码
- freemaker导出word的doc_docx_带动态图片及
- 977个扁平化APP图标图片素材收集
- android使用Apache POI 3.10操作docx替换指定
- SpringMVC上传图片文件到 腾讯云
- Java程序员面试宝典-杨磊_高清版[带完
- 最全的android图片加密
- word提取文字所需jar
- Java高级编程(JDK6英文清晰文字版)
- Android读取doc(支持图片) 转html 并保
- Echarts-Java 3.0.0.6.jar附后台生成图片功
- 在Android中全屏显示GIF图片演示代码
- android 云标签,文字墙(文字随机排列
- 手机文字识别 Android 图像处理 字符识
- android完美图片跑马灯
- 百度OCR的DemoAndroid
- 解决React-Native的WebView不支持Android选择
评论
共有 条评论