資源簡介
tess4j的demo開發,識別圖片技術
代碼片段和文件信息
/**
?*?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?????????????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?????????????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??2014-09-29?11:12??Java_OCR\
?????文件?????????659??2014-09-29?10:54??Java_OCR\.classpath
?????文件?????????384??2014-09-29?09:59??Java_OCR\.project
?????目錄???????????0??2014-09-29?09:59??Java_OCR\.settings\
?????文件?????????598??2014-09-29?09:59??Java_OCR\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2014-09-29?11:11??Java_OCR\bin\
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\com\
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\com\recognition\
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\com\recognition\software\
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\com\recognition\software\jdeskew\
?????文件?????????676??2014-09-29?10:54??Java_OCR\bin\com\recognition\software\jdeskew\ImageDeskew$HoughLine.class
?????文件????????3616??2014-09-29?10:54??Java_OCR\bin\com\recognition\software\jdeskew\ImageDeskew.class
?????文件????????1432??2014-09-29?10:54??Java_OCR\bin\com\recognition\software\jdeskew\ImageUtil.class
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\com\ricky\
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\com\ricky\java\
?????目錄???????????0??2014-09-29?11:12??Java_OCR\bin\com\ricky\java\ocr\
?????文件???????17021??2014-09-29?11:12??Java_OCR\bin\com\ricky\java\ocr\TessAPITest$TessDllAPIImpl.class
?????文件???????17810??2014-09-29?11:12??Java_OCR\bin\com\ricky\java\ocr\TessAPITest.class
?????文件????????4206??2014-09-29?11:12??Java_OCR\bin\com\ricky\java\ocr\Tesseract1Test$Tess1Extension.class
?????文件????????1520??2014-09-29?11:12??Java_OCR\bin\com\ricky\java\ocr\Tesseract1Test$Word.class
?????文件????????5657??2014-09-29?11:12??Java_OCR\bin\com\ricky\java\ocr\Tesseract1Test.class
?????文件????14789120??2014-09-29?11:11??Java_OCR\bin\gsdll64.dll
?????文件?????2120704??2014-09-29?10:34??Java_OCR\bin\liblept168.dll
?????文件?????2000384??2014-09-29?10:34??Java_OCR\bin\libtesseract302.dll
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\net\
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\net\sourceforge\
?????目錄???????????0??2014-09-29?10:54??Java_OCR\bin\net\sourceforge\tess4j\
?????文件????????1334??2014-09-29?10:54??Java_OCR\bin\net\sourceforge\tess4j\ITesseract.class
?????文件?????????552??2014-09-29?10:54??Java_OCR\bin\net\sourceforge\tess4j\TessAPI$ETEXT_DESC.class
?????文件?????????555??2014-09-29?10:54??Java_OCR\bin\net\sourceforge\tess4j\TessAPI$Tessba
?????文件?????????579??2014-09-29?10:54??Java_OCR\bin\net\sourceforge\tess4j\TessAPI$TessMutableIterator.class
............此處省略82個文件信息
評論
共有 條評論