OpenCV android-应用程序崩溃,当我点击bottun,不知道为什么

时间:2017-07-13 13:23:52

标签: android opencv histogram

我对Android上的编程很新。 目前我正在尝试使用Androidstudio和OpenCV制作直方图比较应用程序。不幸的是,当我点击我的onclick功能时,我不知道为什么我的应用程序会被关闭。如果有人可以帮助我,那么代码就在这里,我会非常感激。我已经谷歌搜索了一段时间,但无法找到答案

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    image1 = (ImageView) this.findViewById(R.id.Slika);
    image2 = (ImageView) this.findViewById(R.id.Slika2);
    image1.setClickable(true);
    image2.setClickable(true);
    botun = (Button) this.findViewById(R.id.botun);
    startaj();
}


    public void startaj(){

    image2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            startActivityForResult(photoPickerIntent, SELECT_PHOTO);
            imgNo = 2;

        }
    } );

        image1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0){
                Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
                photoPickerIntent.setType("image/*");
                startActivityForResult(photoPickerIntent, SELECT_PHOTO);
                imgNo = 1;

            }
        });

        botun.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //Određivanje broj kvantizacija
                int huebins=50;
                int satbins=60;

                MatOfInt HistKvant=new MatOfInt(huebins,satbins);
                //Hue razine između 0-179, saturation 0-255
                MatOfFloat histogramrange=new MatOfFloat(0f,180f,0f,256f);

                //Vrijednost histograma spremamo u ovo matricu
                Mat HistValue1=new Mat();
                Mat HistValue2=new Mat();

                //Broj kanala hue/sat
                MatOfInt mChannels=new MatOfInt(0,1);

                //Reduciranje bitmapa da je lakše računanje ( dimenzija )
                bitmap1red=Bitmap.createScaledBitmap(bitmap1,200,200,true);
                bitmap2red=Bitmap.createScaledBitmap(bitmap2,200,200,true);


                //transformacija slika iz Bitmap formata u Mat -> HSV sliku
                Utils.bitmapToMat(bitmap1red,Histoslika1);
                Utils.bitmapToMat(bitmap2red,Histoslika2);

                Imgproc.cvtColor(Histoslika1,Histoslika1,Imgproc.COLOR_BGR2HSV);
                Imgproc.cvtColor(Histoslika2,Histoslika2,Imgproc.COLOR_BGR2HSV);

                Histoslika1.convertTo(Histoslika1, CvType.CV_32F);
                Histoslika2.convertTo(Histoslika2, CvType.CV_32F);


                ArrayList<Mat> histImage1=new ArrayList<Mat>();
                histImage1.add(Histoslika1);

                ArrayList<Mat> histImage2=new ArrayList<Mat>();
                histImage1.add(Histoslika2);


                //računanje Histograma
                Imgproc.calcHist(histImage1, mChannels, new Mat(), HistValue1, HistKvant, histogramrange);
                Core.normalize(HistValue1, HistValue1, 0, HistValue1.rows(), Core.NORM_MINMAX, -1, new Mat());
                Imgproc.calcHist(histImage2, mChannels, new Mat(), HistValue2, HistKvant, histogramrange);
                Core.normalize(HistValue2, HistValue2, 0, HistValue2.rows(), Core.NORM_MINMAX, -1, new Mat());

                double Compareresults=Imgproc.compareHist(HistValue1,HistValue2,Imgproc.CV_COMP_CHISQR);
                double bestresults=0;
                if(Compareresults>bestresults){bestresults=Compareresults;}

                //Slanje rezultata u activity_results;
                Intent intent = new Intent(Main.this, results.class);
                Bundle bundle=new Bundle();
                bundle.putDouble("bestresults",bestresults);
                intent.putExtras(bundle);
                startActivity(intent);
            }

        });


    }

Logcat:

  

07-13 15:24:55.236 19457-19457 /?我/艺术:延迟启用-Xcheck:jni   07-13 15:24:55.434 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_dependencies_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_dependencies_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.615 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_0_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_0_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.661 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_1_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_1_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.707 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_2_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_2_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.764 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_3_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_3_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.814 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_4_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_4_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.875 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_5_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_5_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.917 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_6_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_6_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.959 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_7_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_7_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:55.999 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_8_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_8_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:56.045 19457-19457 / com.example.kresimir.imagedetect W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction -set = arm64 --instruction-set-features = smp,a53 --runtime-arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default --dex-file = / data / app / com.example.kresimir.imagedetect-1 / split_lib_slice_9_apk.apk --oat-file = / data /dalvik-cache/arm64/data@app@com.example.kresimir.imagedetect-1@split_lib_slice_9_apk.apk@classes.dex)因为非0退出状态   07-13 15:24:56.054 19457-19457 / com.example.kresimir.imagedetect I / InstantRun:启动即时运行服务器:是主进程   07-13 15:24:56.125 19457-19457 / com.example.kresimir.imagedetect I / HwCust:为类android.app.HwCustHwWallpaperManagerImpl找到的构造函数   07-13 15:24:56.154 19457-19457 / com.example.kresimir.imagedetect W / art:在Android 4.1之前,方法android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter ,android.content.res.ColorStateList,android.graphics.PorterDuff $ Mode)会错误地覆盖android.graphics.drawable.Drawable中的package-private方法   07-13 15:24:56.320 19457-19457 / com.example.kresimir.imagedetect I / HwSecImmHelper:mSecurityInputMethodService为null   07-13 15:24:56.399 19457-19531 / com.example.kresimir.imagedetect I / OpenGLRenderer:初始化的EGL,版本1.4   07-13 15:24:56.452 19457-19457 / com.example.kresimir.imagedetect W / art:在Android 4.1之前,方法int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int,boolean)会错误地覆盖android.widget.ListView中的package-private方法   07-13 15:24:56.658 19457-19457 / com.example.kresimir.imagedetect E / art:找不到长期org.opencv.core.Mat.n_Mat()的实现(试过Java_org_opencv_core_Mat_n_1Mat和Java_org_opencv_core_Mat_n_1Mat__)   07-13 15:24:56.678 19457-19457 / com.example.kresimir.imagedetect I / Process:发送信号。 PID:19457 SIG:9

0 个答案:

没有答案