Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenCV结合拉普拉斯公式检测Android中图像是否模糊_Android_Opencv_Blurry - Fatal编程技术网

OpenCV结合拉普拉斯公式检测Android中图像是否模糊

OpenCV结合拉普拉斯公式检测Android中图像是否模糊,android,opencv,blurry,Android,Opencv,Blurry,在Ios中,我们可以: 我不知道如何在Android或Java中检测图像是否模糊?private void opencvProcess(){ private void opencvProcess() { BitmapFactory.Options options = new BitmapFactory.Options(); options.inDither = true; options.inPreferredConfig = Bitmap.Config.ARG

在Ios中,我们可以:

我不知道如何在Android或Java中检测图像是否模糊?

private void opencvProcess(){
    private void opencvProcess() {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inDither = true;
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap image = decodeSampledBitmapFromFile(picFilePath, options, 2000, 2000);
    int l = CvType.CV_8UC1; //8-bit grey scale image
    Mat matImage = new Mat();
    Utils.bitmapToMat(image, matImage);
    Mat matImageGrey = new Mat();
    Imgproc.cvtColor(matImage, matImageGrey, Imgproc.COLOR_BGR2GRAY);

    Bitmap destImage;
    destImage = Bitmap.createBitmap(image);
    Mat dst2 = new Mat();
    Utils.bitmapToMat(destImage, dst2);
    Mat laplacianImage = new Mat();
    dst2.convertTo(laplacianImage, l);
    Imgproc.Laplacian(matImageGrey, laplacianImage, CvType.CV_8U);
    Mat laplacianImage8bit = new Mat();
    laplacianImage.convertTo(laplacianImage8bit, l);

    Bitmap bmp = Bitmap.createBitmap(laplacianImage8bit.cols(), laplacianImage8bit.rows(), Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(laplacianImage8bit, bmp);
    int[] pixels = new int[bmp.getHeight() * bmp.getWidth()];
    bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight()); // bmp为轮廓图

    int maxLap = -16777216; // 16m
    for (int pixel : pixels) {
        if (pixel > maxLap)
            maxLap = pixel;
    }

    int soglia = -6118750;
    if (maxLap <= soglia) {
        System.out.println("is blur image");
    }
    soglia += 6118750;
    maxLap += 6118750;
    LogUtil.log("图片位置=" + picFilePath
            + "\nimage.w=" + image.getWidth() + ", image.h=" + image.getHeight()
            + "\nmaxLap= " + maxLap + "(清晰范围:0~6118750)"
            + "\n" + Html.fromHtml("<font color='#eb5151'><b>" + (maxLap <= soglia ? "模糊" : "清晰") + "</b></font>"));
    opencvEnd = true;
    isBlur = maxLap <= soglia;
}
BitmapFactory.Options=new-BitmapFactory.Options(); options.inDither=true; options.inPreferredConfig=Bitmap.Config.ARGB_8888; 位图图像=decodeSampledBitmapFromFile(picFilePath,options,2000,2000); int l=CvType.CV_8UC1;//8位灰度图像 Mat matImage=新Mat(); Utils.bitmapToMat(图像,matImage); Mat MATIMAGEREY=新Mat(); Imgproc.CVT颜色(matImage、MATIMAGEREY、Imgproc.COLOR_BGR2GRAY); 位图去图像; destImage=Bitmap.createBitmap(图像); Mat dst2=新Mat(); Utils.bitmapToMat(目标图像,dst2); Mat laplacianImage=新Mat(); dst2.convertTo(拉普拉斯图像,l); Imgproc.Laplacian(MatimageGray,laplacianImage,CvType.CV_8U); Mat laplacianImage8bit=新Mat(); laplacianImage.convertTo(laplacianImage8bit,l); 位图bmp=Bitmap.createBitmap(laplacianImage8bit.cols(),laplacianImage8bit.rows(),Bitmap.Config.argb8888); Utils.matToBitmap(laplacianImage8bit,bmp); int[]像素=新的int[bmp.getHeight()*bmp.getWidth()]; bmp.getPixels(像素,0,bmp.getWidth(),0,0,bmp.getWidth(),bmp.getHeight());//bmp为轮廓图 int maxLap=-16777216;//16m 用于(整数像素:像素){ 如果(像素>最大重叠) maxLap=像素; } int-soglia=-6118750;
if(maxLap)你能分享一下你在IOS中是如何做到这一点的吗?这在所有情况下都有效吗?它会将一些适当的图像作为模糊图像进行推断这些方法对小尺寸图像很有效。但是,当我检查大尺寸图像时,应用程序崩溃了。对我来说,它是不同的。在大图片上效果很好。不知何故,如果图片是全景或是小像素,它会崩溃。