当前位置: 首页 > 知识库问答 >
问题:

在Android studio中使用Tesseract ocr,但程序意外退出

岑和风
2023-03-14

我在Android Studio中使用Tesseract来识别图片中的文本。当我像这样调用以下函数时:

String textResult = doOcr(bitmapTreated,"eng"); 
public String doOcr(Bitmap bitmap, String language) {
        TessBaseAPI baseApi = new TessBaseAPI();
        baseApi.init(getSDPath(), language);
        bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
        baseApi.setImage(bitmap);
        String text = baseApi.getUTF8Text();
        baseApi.clear();
        baseApi.end();
        return text;
    } 
06-24 21:37:23.205 30643-30643/? D/dalvikvm: Late-enabling CheckJNI
06-24 21:37:23.335 30643-30643/com.example.text_recognization D/dalvikvm: GetMethodID: not returning static method Landroid/os/Process;.getTotalMemory ()J
06-24 21:37:23.335 30643-30643/com.example.text_recognization D/dalvikvm: GetMethodID: not returning static method Landroid/os/Process;.getFreeMemory ()J
06-24 21:37:23.365 30643-30643/com.example.text_recognization I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
06-24 21:37:23.365 30643-30643/com.example.text_recognization W/dalvikvm: VFY: unable to resolve virtual method 422: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
06-24 21:37:23.365 30643-30643/com.example.text_recognization D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
06-24 21:37:23.365 30643-30643/com.example.text_recognization I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
06-24 21:37:23.365 30643-30643/com.example.text_recognization W/dalvikvm: VFY: unable to resolve virtual method 444: Landroid/content/res/TypedArray;.getType (I)I
06-24 21:37:23.365 30643-30643/com.example.text_recognization D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
06-24 21:37:23.435 30643-30643/com.example.text_recognization I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.2.2.1_RB1.04.04.04.090.052_msm8974_LNX.LA.3.5.2.2.1_RB1__release_AU ()
                                                                                     OpenGL ES Shader Compiler Version: E031.24.00.15
                                                                                     Build Date: 07/01/15 Wed
                                                                                     Local Branch: mybranch11515920
                                                                                     Remote Branch: quic/LNX.LA.3.5.2.2.1_rb1
                                                                                     Local Patches: NONE
                                                                                     Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.2.2.1_RB1.04.04.04.090.052 +  NOTHING
06-24 21:37:23.465 30643-30643/com.example.text_recognization D/OpenGLRenderer: Enabling debug mode 0
06-24 21:37:23.525 30643-30643/com.example.text_recognization I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@43519b38 time:579991957
static {
        System.loadLibrary("lept");
        System.loadLibrary("tess"); 
        nativeClassInit();
    }
com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    defaultConfig {
        applicationId "com.example.zhouying.text_recognization"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile files('libs/tess-two.tesseract3.01-leptonica1.68-LibJPEG6b.jar')
}
compile 'com.android.support:appcompat-v7:22.0.1'

会有一条红线表示“支持库不应该使用与CompilesDKVersion不同的版本”。然后我将compileSdkVersion和targetSdkVersion更改为22,我可以看到错误。

Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(24) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/Library/Android/sdk/build-tools/23.0.2/aapt'' finished with non-zero exit value 1

我可以在“compile'com.android.support:design:23.1.1'”下面看到一条红线。我继续将其更改为“compile'com.android.support:design:22.0.1'。它显示

Failed to resolve com.android.support:appcompat-v7:22.0.1
Failed to resolve com.android.support:design:22.0.1

共有1个答案

仲孙文乐
2023-03-14

这可能是由于某些版本的Android支持库中的bug造成的。

尝试更新您的支持库:

compile 'com.android.support:appcompat-v7:22.1.0'
 类似资料:
  • 我正在尝试在python中使用selenium,由于某种原因我无法修改PATH,因此我只能指定浏览器驱动程序的位置。但是,我尝试了几个驱动程序,但都不起作用。 环境:Windows 7,Anaconda3-python3.6.1,selenium3.4.3,chrome59.0.3071.115(官方构建)(64位),chromedriver2.30(win32)。 这里是我尝试过的一部分代码和相

  • 我刚刚安装了MacOSX和Mavericks(10.9.2)。安装了JDK1.7.0_ 55。一切似乎都安装正确。我下载了EclipseKepler4.3.2并解压缩到我的应用程序文件夹。我再次检查了安装情况。启动应用程序时,我会收到以下错误消息: 我检查了我的控制台输出,并在Eclipse错误报告中得到以下内容: 异常类型:EXC _坏_访问(SIGSEGV)异常代码:KERN _ INVALI

  • 我正试图在Mac OS X上运行一个在windows上运行的项目。该项目使用OpenGL和PyQt库。使用OpenGL库时似乎出现了问题。 我下载了一个螺旋的OpenGL演示。 返回OpenGL:b'2.1 NVIDIA-10.0.51 310.90.10.05b12' 当我尝试运行另一个项目时,PyCharm意外退出,我得到以下结果: Mac信息图片 项目链接 主窗口。py公司 gamewidg

  • 昨天,我刚刚在Mac OS Catalina 10.15.7版上安装了面向企业Java和Web开发人员的Eclipse IDE。我拖动日食。从下载文件夹到应用程序文件夹的应用程序。它工作得很好。我创建了几个servlet。但今天,当我点击应用程序打开它时,我收到了一个问题报告(错误),所以它没有打开。 错误详细信息为。。 启动后的唤醒时间:3300秒 系统完整性保护:启用 崩溃的线程:0 异常类型

  • 我想做一个应用程序,使用谷歌翻译API。自从我添加了 我的构建中的依赖项。gradle我有个错误: 现在必须显式声明注释处理器。发现编译类路径上的以下依赖项包含注释处理器。请将它们添加到annotationProcessor配置中。-自动值-1.2。jar(com.google.auto.value:auto-value:1.2)或者,设置android。defaultConfig。javaCom

  • 这款应用在android 2.2中运行得非常好。但在4.2中,该应用程序意外关闭。该应用程序使用客户端服务器架构向充当服务器的笔记本电脑发送消息。logcat显示: 我的客户代码是 请帮我解决它。