java - Distance transform in OpenCV output error -
i'm using android binaries , first time i'm performing distance transform in opencv. opencv specification says output image of distancetransform 32-bit floating-point, single-channel image. mat (mdist), on creating bitmap out of mat throws illegalstateexception. due incompatibility of output , mat object? have specify color channel details mat or anything? following code portion.
mat mimg = new mat(); mat mthresh = new mat(); mat mdist = new mat(); imageview imgview = (imageview) findviewbyid(r.id.imageview); bitmap bmpin = bitmapfactory.decoderesource(getresources(), r.drawable.w1); utils.bitmaptomat(bmpin, mimg); //load image mat imgproc.cvtcolor(mimg, mimg, imgproc.color_bgr2gray); imgproc.threshold(mimg, mthresh, 0, 255, imgproc.thresh_binary | imgproc.thresh_otsu); //grayscale , thresholding imgproc.distancetransform(mthresh, mdist, imgproc.cv_dist_l2, imgproc.cv_dist_mask_precise); bitmap bmpout = bitmap.createbitmap(mdist.cols(), mdist.rows(), bitmap.config.argb_8888); utils.mattobitmap(mdist, bmpout); //error in creating bitmap imgview.setimagebitmap(bmpout);
the fault in following line of code;
bitmap bmpout = bitmap.createbitmap(mdist.cols(), mdist.rows(), bitmap.config.argb_8888);
the bitmap.config should applied not argb_8888. function creates 8-bit single channel mat.
Comments
Post a Comment