Javacv cvSaveImage()致命错误

时间:2018-08-24 04:11:46

标签: android-studio javacv

我正在使用一个应用程序来扫描收据并检测产品金额。无论如何,在调用cvSaveImage()时我遇到了致命错误。

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_UNCAUGHT_CXX_EXCEPTION (0xe06d7363) at pc=0x00007ffb245ea388, pid=12972, tid=0x0000000000000730
#
# JRE version: OpenJDK Runtime Environment (8.0_152-b02) (build 1.8.0_152-release-1024-b02)
# Java VM: OpenJDK 64-Bit Server VM (25.152-b02 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [KERNELBASE.dll+0x3a388]
#
# 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:
# C:\Users\Iden\AndroidStudioProjects\Scanner\hs_err_pid12972.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

这是令人讨厌的代码,以及我正在测试的驱动程序方法:

/**
 * Resize an image by a given percent
 * @param srcImage The image to be resized
 * @param percent The percentage to resize it by
 * @return Resized image
 */
private IplImage downScaleImage(IplImage srcImage, int percent) {
    System.out.println("srcImage - height - " + srcImage.height() +
            ", width - " + srcImage.width());
    IplImage destImage = cvCreateImage(cvSize((srcImage.width() * percent) / 100,
            (srcImage.height() * percent) / 100), srcImage.depth(), srcImage.nChannels());
    cvResize(srcImage, destImage);
    System.out.println("destImage - height - " + destImage.height() +
            ", width - " + destImage.width());
    return destImage;
}

/**
 * Detect the edges of an image using the canny edge detect method given
 * a percent in order to reduce the size of the image and be able to process it better
 *
 * @param srcImage Image to detect edges of
 * @param percent percentage to reduce image
 * @return Image with edge detection
 */
private IplImage edgeDetection(IplImage srcImage, int percent) {
    IplImage destImage = downScaleImage(srcImage, percent);
    IplImage grayImage = cvCreateImage(cvGetSize(destImage), IPL_DEPTH_8U, 1);

    //Convert to gray
    cvCvtColor(destImage, grayImage, CV_BGR2GRAY);
    OpenCVFrameConverter.ToMat converterToMat = new OpenCVFrameConverter.ToMat();
    Frame grayImageFrame = converterToMat.convert(grayImage);
    Mat grayImageMat = converterToMat.convert(grayImageFrame);

    //Apply gaussian blur
    GaussianBlur(grayImageMat, grayImageMat, new Size(5, 5), 0.0, 0.0, BORDER_DEFAULT);

    //grayImageFrame = converterToMat.convert(grayImageMat);
    destImage = converterToMat.convertToIplImage(grayImageFrame);

    //Clean it for better detection
    cvErode(destImage, destImage);
    cvDilate(destImage, destImage);

    //Apply the canny edge detection method
    cvCanny(destImage, destImage, 75.0, 200.0);
    if (destImage != null) {
        File f = new File(System.getProperty("user.home") + File.separator + "s.jpg");
        cvSaveImage(f.getAbsolutePath(), destImage);
    }
    return destImage;
}

public static void main(String[] args) {
    File receiptImageFile = new File("C:\\Users\\Iden\\Pictures\\receipt.jpg");
    IplImage receiptImage = cvLoadImage(receiptImageFile.getAbsolutePath());
    ReceiptScannerImpl r = new ReceiptScannerImpl();
    r.edgeDetection(receiptImage, 50);

}

我尝试在Android Studio中重新安装android sdk和JRE。任何帮助将不胜感激。抱歉,没有代码!

0 个答案:

没有答案