Fatal error: Failed to write core dump

拟墨画扇 提交于 2019-12-25 02:53:50

问题


I'm trying to run the unit tests in the tess4j distribution currently. And while running one of the unit tests, java crashed with the following error:

TessBaseAPIGetIterator
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6718f834, pid=5612, tid=3592
#
# JRE version: 7.0_17-b02
# Java VM: Java HotSpot(TM) Client VM (23.7-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C  [libtesseract302.dll+0xf834]  tesseract::TessBaseAPI::Init+0x34
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# G:\Final year project\eclipse stuff\Testings\hs_err_pid5612.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Can i please get help? i'm fairly sure that the DLL file is not corrupt and neither is my harddisk. i'm using the Windows 8 OS and the latest version of eclipse to build the project.

The code is:

import java.io.File;
import net.sourceforge.tess4j.*;

import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.*;
import java.util.Arrays;
import javax.imageio.ImageIO;
    import net.sourceforge.tess4j.TessAPI1.*;
import net.sourceforge.vietocr.ImageIOHelper;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

public class TesseractExample{
String datapath = "G:\\Final year project\\eclipse stuff\\tessdemo\\tessdata";
String language = "eng";
String expOCRResult = "The (quick) [brown] {fox} jumps!\nOver the $43,456.78 <lazy> #90 dog";

TessAPI1.TessBaseAPI handle;

public void testResultIterator() throws Exception {
    System.out.println("TessBaseAPIGetIterator");
    String lang = "eng";
    File tiff = new File("eurotext.tif");
    BufferedImage image = ImageIO.read(new FileInputStream(tiff)); // require jai-imageio lib to read TIFF
    ByteBuffer buf = ImageIOHelper.convertImageData(image);
    int bpp = image.getColorModel().getPixelSize();
    int bytespp = bpp / 8;
    int bytespl = (int) Math.ceil(image.getWidth() * bpp / 8.0);
    TessAPI1.TessBaseAPIInit3(handle, datapath, lang);
    TessAPI1.TessBaseAPISetPageSegMode(handle, TessAPI1.TessPageSegMode.PSM_AUTO);
    TessAPI1.TessBaseAPISetImage(handle, buf, image.getWidth(), image.getHeight(), bytespp, bytespl);
    TessAPI1.TessBaseAPIRecognize(handle, null);
    TessAPI1.TessResultIterator ri = TessAPI1.TessBaseAPIGetIterator(handle);
    TessAPI1.TessPageIterator pi = TessAPI1.TessResultIteratorGetPageIterator(ri);
    TessAPI1.TessPageIteratorBegin(pi);
    System.out.println("Bounding boxes:\nchar(s) left top right bottom confidence font-attributes");

    int height = image.getHeight();
     do {
        Pointer ptr = TessAPI1.TessResultIteratorGetUTF8Text(ri, TessAPI1.TessPageIteratorLevel.RIL_WORD);
        String word = ptr.getString(0);
        TessAPI1.TessDeleteText(ptr);
        float confidence = TessAPI1.TessResultIteratorConfidence(ri, TessAPI1.TessPageIteratorLevel.RIL_WORD);
        IntBuffer leftB = IntBuffer.allocate(1);
        IntBuffer topB = IntBuffer.allocate(1);
        IntBuffer rightB = IntBuffer.allocate(1);
        IntBuffer bottomB = IntBuffer.allocate(1);
        TessAPI1.TessPageIteratorBoundingBox(pi, TessAPI1.TessPageIteratorLevel.RIL_WORD, leftB, topB, rightB, bottomB);
        int left = leftB.get();
        int top = topB.get();
        int right = rightB.get();
        int bottom = bottomB.get();
        System.out.print(String.format("%s %d %d %d %d %f", word, left, top, right, bottom, confidence));
       System.out.println(String.format("%s %d %d %d %d", str, left, height - bottom, right, height - top)); // training box coordinates     

        IntBuffer boldB = IntBuffer.allocate(1);
        IntBuffer italicB = IntBuffer.allocate(1);
        IntBuffer underlinedB = IntBuffer.allocate(1);
        IntBuffer monospaceB = IntBuffer.allocate(1);
        IntBuffer serifB = IntBuffer.allocate(1);
        IntBuffer smallcapsB = IntBuffer.allocate(1);
        IntBuffer pointSizeB = IntBuffer.allocate(1);
        IntBuffer fontIdB = IntBuffer.allocate(1);
        String fontName = TessAPI1.TessResultIteratorWordFontAttributes(ri, boldB, italicB, underlinedB,
                monospaceB, serifB, smallcapsB, pointSizeB, fontIdB);
        boolean bold = boldB.get() == TessAPI1.TRUE;
        boolean italic = italicB.get() == TessAPI1.TRUE;
        boolean underlined = underlinedB.get() == TessAPI1.TRUE;
        boolean monospace = monospaceB.get() == TessAPI1.TRUE;
        boolean serif = serifB.get() == TessAPI1.TRUE;
        boolean smallcaps = smallcapsB.get() == TessAPI1.TRUE;
        int pointSize = pointSizeB.get();
        int fontId = fontIdB.get();
        System.out.println(String.format("  font: %s, size: %d, font id: %d, bold: %b," +
                   " italic: %b, underlined: %b, monospace: %b, serif: %b, smallcap: %b", 
                fontName, pointSize, fontId, bold, italic, underlined, monospace, serif, smallcaps));            
    } while (TessAPI1.TessPageIteratorNext(pi, TessAPI1.TessPageIteratorLevel.RIL_WORD) == TessAPI1.TRUE);


}

public static void main(String[] args) {
    TesseractExample instance=new TesseractExample();

   try {

instance.testResultIterator();

    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
}
}

Thank you!


回答1:


Looks like handle has not been initialized.

handle = TessAPI1.TessBaseAPICreate();


来源:https://stackoverflow.com/questions/15758031/fatal-error-failed-to-write-core-dump

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!