当前位置: 首页>>代码示例>>Java>>正文


Java TesseractException.printStackTrace方法代码示例

本文整理汇总了Java中net.sourceforge.tess4j.TesseractException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java TesseractException.printStackTrace方法的具体用法?Java TesseractException.printStackTrace怎么用?Java TesseractException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sourceforge.tess4j.TesseractException的用法示例。


在下文中一共展示了TesseractException.printStackTrace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map

import net.sourceforge.tess4j.TesseractException; //导入方法依赖的package包/类
public void map(LongWritable key, Text url, OutputCollector<Text, Text> output, Reporter reporter) throws IOException {

            File videoDownloadDir = Files.createTempDir();
            VGet v = new VGet(new URL(url.toString()), videoDownloadDir);
            v.download();
            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
            File[] videoFiles = videoDownloadDir.listFiles();
            Arrays.sort(videoFiles);
            File[] videoFramesFiles = VideoProcessing.parseVideo(videoFiles[0], 70);
            File[] processedVideoFrames = VideoProcessing.cutImages(videoFramesFiles);

            Tesseract instance = Tesseract.getInstance();
            instance.setDatapath("/usr/share/tesseract-ocr");
            instance.setTessVariable("LC_NUMERIC", "C");

            for (File image: processedVideoFrames) {
                String result = null;
                try {
                    result = instance.doOCR(image);
                } catch (TesseractException e) {
                    e.printStackTrace();
                }
                if (!result.isEmpty()) {
                    word.set(result);
                    output.collect(url, word);
                }
            }
        }
 
开发者ID:yurinnick,项目名称:hadoop-video-ocr,代码行数:29,代码来源:HadoopOCR.java

示例2: ocr

import net.sourceforge.tess4j.TesseractException; //导入方法依赖的package包/类
/**
 *
 *
 * @param file
 * @param originalPath
 * @param language
 * @return
 */
private String ocr(File file, String originalPath, String language) {
  // TODO:
  Tesseract1 instance = new Tesseract1();
  instance.setPageSegMode(PSM_MODE);
  instance.setDatapath(TESSERACT_FOLDER);
  instance.setLanguage(language);
  try {
    String result = instance.doOCR(file);
    return result;
  } catch (TesseractException e) {
    e.printStackTrace();
  }

  return null;
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:24,代码来源:ImageTextExtractorTess4j.java

示例3: OCR

import net.sourceforge.tess4j.TesseractException; //导入方法依赖的package包/类
public String OCR(SerializableImage image) {
	try {
		String hh = Tesseract.getInstance().doOCR(image.getImage());
		// System.out.println(hh);
		log.info("Read: " + hh);
		return hh;
	} catch (TesseractException e) {
		e.printStackTrace();
	}
	return null;

}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:13,代码来源:TesseractOCR.java

示例4: ocr

import net.sourceforge.tess4j.TesseractException; //导入方法依赖的package包/类
public String ocr(BufferedImage image) {
  try {
    String hh = Tesseract.getInstance().doOCR(image);
    // System.out.println(hh);
    log.info("Read: " + hh);
    return hh;
  } catch (TesseractException e) {
    e.printStackTrace();
  }
  return null;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:12,代码来源:TesseractOcr.java

示例5: processPageWithTessaract

import net.sourceforge.tess4j.TesseractException; //导入方法依赖的package包/类
public int[] processPageWithTessaract(ArrayList<InftyCDBEntry> chars, byte[][] img, boolean saveErros){	
		int eCount = 0, sampleCount =0; 
		byte[][] p = null, pt = null;
		int[] charErrors = new int[26];
		for(int i=0; i<chars.size(); i++){//charsA.size()
			InftyCDBEntry e = chars.get(i);
			String entity = e.entity.toLowerCase().trim();
			if(entity.length()>1) continue;	// Continue if string is more than one character long;
			//Center Img
			pt = ITools.crop(e.left, e.top, e.right, e.bottom, img);
			int[] s  = {pt.length, pt[0].length};
			int[] cent = GCRTools.getCentroidLocation(pt);
			int nW = s[1] + Math.abs(cent[0]), nH = s[0] + Math.abs(cent[1]);
			int nS = nH;
			if(nW>nS) nS = nW;
			int nX = 0, nY = 0, offX = (nS-s[1])/2, offY = (nS-s[0])/2;
			p = new byte[nS][nS];
			for(int y=0; y<nS; y++){
				nY = y-cent[1]-offY;
				if(nY>=0 && nY<s[0]){
					for(int x=0; x<nS; x++){
						nX = x-cent[0]-offX;
						if(nX>=0 && nX<s[1]){
							p[y][x] = pt[nY][nX];
						}
					}
				}
			}
			//End center Img
			char c = entity.charAt(0);
			try {
				String result = tessaract.doOCR(ImageManipulation.getGrayBufferedImage(pt));
				result = result.trim();
				if(result.toCharArray().length==0 || result.toCharArray().length>1 || result.charAt(0)!=c){
					eCount++;
				}
			} catch (TesseractException e1) {
				e1.printStackTrace();
			}
			if((int)percent != lastP){
				lastP = (int)percent;
//				gui.testingResults.append(lastP+"%\n");
			}
			sampleCount++;
			totalCharCount[c-97]++;
			percent = sampleCount*100.0f/(float)chars.size();
		}
		return new int[]{eCount, sampleCount};
	}
 
开发者ID:hmart027,项目名称:GrayscaleCharacterRecognition,代码行数:50,代码来源:GCRMain.java


注:本文中的net.sourceforge.tess4j.TesseractException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。