适用于Android应用程序tess4j的OCR [英] OCR for android application tess4j

查看:346
本文介绍了适用于Android应用程序tess4j的OCR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上是在设计一个应用程序,该应用程序将从android设备默认相机捕获图像并在图像视图中显示该图像!工作正常!足够好!

Basically am designing an application that will capture an image from the android devices default camera and will display that image in an image view! works fine! good enough!

capt_but.setOnClickListener(new View.OnClickListener()
    {
        //@Override
    // TODO Auto-generated method stub          
             public void onClick(View v)
             {
                 Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
                 startActivityForResult(cameraIntent, CAMERA_REQUEST); 
             }
    }); 
}
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {  
       if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) 
       {  
            Bitmap photo = (Bitmap) data.getExtras().get("data"); 
            imageView.setImageBitmap(photo);
       }  
    }

我的下一个任务是应用tess4j OCR功能,该功能基本上将从我捕获的图像中提取字符! tess4j基本上是tesseract OCR的Java包装器! 我正在ECLIPSE中编程! 这是它的链接!

My next task is to apply tess4j OCR functionality that will basically extract characters from the image i captured! tess4j is basically a java wrapper for the tesseract OCR! Am Programming in ECLIPSE! Here is the link for it!

tess4j.sourceforge.net

tess4j.sourceforge.net

我将所有可以在开源文件中找到的jar添加到了我创建的文件夹中,该文件夹是eclipse中主项目目录的lib!我全部选中了它们,还添加了它们以构建路径!

I added all the jars i could find in the open source files and added them to a folder i made that is lib to the main project directory in eclipse! i selected them all and also added them to build path!

然后,我将所有可以找到的dll复制到主项目目录中! 然后在上面同一链接上使用一个示例,我对我的代码进行了如下编程:

then i copied all the dll's i could find to the main project directory! Then using one example on the same link above i programmed my code as follows:

public void myfunction(Intent data)
    {
        Bitmap photo = (Bitmap) data.getExtras().get("data");
        Tesseract instance = Tesseract.getInstance(); // JNA Interface Mapping
        File imageFile = new File("myimage.tif");
        try 
        {   
            String result = instance.doOCR(imageFile)
            System.out.println(result);
        } 
        catch (TesseractException e)
        {
            System.err.println(e.getMessage());
        }
    }

我的项目正在拾取tesseract jar的文件,并使我能够浏览上的函数目录.操作员! 但是在线上,

My project is picking up the tesseract jar's and is enabling me to browse function directory on . operator! However on line,

String result = instance.doOCR(imageFile)

我得到的错误是:

无法解析类型java.awt.image.BufferedImage.从所需的.class文件间接引用

The type java.awt.image.BufferedImage cannot be resolved. It is indirectly referenced from required .class files

快速解决方法是: 配置构建路径!

the quick fix is: Configure build path!

我不知道这是什么问题!正在努力找出问题所在!我在上面提到的步骤中缺少什么吗?我下载的tess4j也有其他文件!友善的助手从上面的链接下载tess4j,以检查下载中的文件!任何XML问题?或任何构建路径问题?

I cnt figure out what is the problem! am trying hard to figure out the problem! am i missing something from the steps i mentioned above? the tess4j i downloaded also had other files! kindly helper download the tess4j from the link above to examine the files that are in the download! any xml problem? or any build path problem??

推荐答案

无法解析类型java.awt.image.BufferedImage.

The type java.awt.image.BufferedImage cannot be resolved.

从该错误消息来看,Android平台似乎不支持BufferedImage类. Android API 不包含java.awt.image包.

From that error message, it seems that BufferedImage class is not supported on Android platform. Android API does not include the java.awt.image package.

这篇关于适用于Android应用程序tess4j的OCR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆