Bad detection in edge Detection opencv android

0

I would make a edge detection app in Android with opencv. But I got bad edge detected photo.

Codes :

if (extras != null) {
            String value = extras.getString("key");
            Uri uri = Uri.parse(value);

            Bitmap bitmapOriginal = null;

            try {
                bitmapOriginal = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
            } catch (IOException e) {
                e.printStackTrace();
            }

            Bitmap bitmap = resizeImage(boya.this, bitmapOriginal, 400, 400);

            int width = bitmap.getWidth();
            int height = bitmap.getHeight();

            Bitmap bitmapResult = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);

            Mat mat = new Mat();
            Utils.bitmapToMat(bitmap, mat);

            Mat gray = new Mat();
            Imgproc.cvtColor(mat, gray, Imgproc.COLOR_RGB2GRAY);

            Mat canny = new Mat();
            Imgproc.Canny(gray, canny, 100, 200);

            Utils.matToBitmap(canny, bitmapResult);

            int length = bitmapResult.getWidth()*bitmapResult.getHeight();
            int[] array = new int[length];
            bitmapResult.getPixels(array,0,bitmapResult.getWidth(),0,0,bitmapResult.getWidth(),bitmapResult.getHeight());
            for (int i=0;i<length;i++){

            // If the bitmap is in ARGB_8888 format

                if (array[i] == 0xff000000){
                    array[i] = 0xffffffff;
                } else if(array[i] == 0xffffffff){
                    array[i] = 0xff000000;
                }
            }

        bitmapResult.setPixels(array,0,bitmapResult.getWidth(),0,0,bitmapResult.getWidth(),bitmapResult.getHeight());

            resimiv.setImageBitmap(resizeImage(boya.this, bitmapResult, 400, 400));
        }

Photo Original :

orijinal

Photo Result :

result

Photo wad bad edge detection and converted.

How I can resolve this problem?

I need your help.

android
asked on Stack Overflow Jun 3, 2020 by Egen

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0