I use grabCut in my app, but the program always had no response when "GrabCut begins" appeared in logcat.
Is it a format problem or something else? I use Android OpenCV-2.3.1 library.
...............
Bitmap bitmap = BitmapFactory.decodeFile(mCurrentImagePath);
Log.i(TAG, mCurrentImagePath);
//JPEG2RGB888
bitmap = JPEG2RGB888(bitmap);
Log.i(TAG, "JPEG2RGB888");
//GrabCut part
ma_img=Utils.bitmapToMat(bitmap);
Rect rect;
Point p1, p2;
p1 = new Point(0,0);
p2 = new Point(ma_img.cols(),ma_img.rows());
rect=new Rect(p1,p2);
mask = new Mat();
fgdModel = new Mat();
bgdModel = new Mat();
ma_img.convertTo(ma_img, CvType.CV_8UC3);
Log.i(TAG, "Grabcut begins");
Imgproc.grabCut(ma_img, mask, rect, bgdModel, fgdModel, 0, Imgproc.GC_INIT_WITH_RECT);
Imgproc.grabCut(ma_img, mask, rect, bgdModel, fgdModel, 2);
Log.i(TAG, "Grabcut ends");
//Imgproc.cvtColor(mask, mask, Imgproc.COLOR_GRAY2RGBA, 4);
//convert to Bitmap
Log.i(TAG, "Convert to Bitmap");
bitmap = Bitmap.createBitmap(mask.cols(), mask.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mask, bitmap);
//release MAT part
ma_img.release();
mask.release();
fgdModel.release();
bgdModel.release();
mImageView.setImageBitmap(bitmap);