I am not able to select objects from image after using fill contours in android

asked 2016-12-06 06:23:58 -0600

    mIntermediateMat= new Mat();

    Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.al);;
    Mat rgba= new Mat(bmp.getHeight(), bmp.getWidth(), CvType.CV_8UC1);
    Utils.bitmapToMat(bmp, rgba);



    Size sizeRgba = rgba.size();

    Mat rgbaInnerWindow;

    int rows = (int) sizeRgba.height;
    int cols = (int) sizeRgba.width;

    int left = cols / 19;
    int top = rows / 19;
    int width = cols * 15/16;


    int height = rows * 15/16 ;



    rgbaInnerWindow = rgba.submat(top, top + height, left, left + width);




    Imgproc.Canny(rgbaInnerWindow, mIntermediateMat, 5, 35);


    rgbaInnerWindow.setTo(new Scalar(0, 0, 0, 255), mIntermediateMat);


    List<MatOfPoint> contours = mDetector.getContours();
    Log.e(TAG, "Contours count: " + contours.size());
    Imgproc.drawContours(rgbaInnerWindow, contours, -1, CONTOUR_COLOR);





    Bitmap resultBitmap = Bitmap.createBitmap(rgba.cols(),rgba.rows(),Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(rgba, resultBitmap);

    imageView.setImageBitmap(resultBitmap);
edit retag flag offensive close merge delete

Comments

1

your "rgba" mat has a single channel only ?

berak gravatar imageberak ( 2016-12-06 06:55:51 -0600 )edit

Sorry to reply you late, I have just used channels() function to find out the number of channels of 'rgba' mat and it came out out to be 4.

parasgrover91 gravatar imageparasgrover91 ( 2016-12-06 23:36:18 -0600 )edit