I want to implement Grabcut using Mask. But its is giving me the assertion error.
Here is my Image:
Here is my mask :
Please need urgent help.Thanks
1 | initial version |
I want to implement Grabcut using Mask. But its is giving me the assertion error.
Here is my Image:
Here is my mask :
Please need urgent help.Thanks
2 | retagged |
I want to implement Grabcut using Mask. But its is giving me the assertion error.
Here is my Image:
Here is my mask :
Please need urgent help.Thanks
3 | No.3 Revision |
I want to implement Grabcut using Mask. But its is giving me the assertion error.
Error:OpenCV Error: Bad argument (mask element value must be equelGC_BGD or GC_FGD or GC_PR_BGD or GC_PR_FGD)
Here is my Image:
Here is my mask :
Please need urgent help.Thanks
4 | No.4 Revision |
I want to implement Grabcut using Mask. But its is giving me the assertion error.
Code:
Mat firstMask = new Mat();
Mat bgModel = new Mat();
Mat fgModel = new Mat();
Mat mask;
Mat source = new Mat(1, 1, CvType.CV_8U, new Scalar(3.0));
dst = new Mat();
Rect rect = new Rect(tl, br);
firstMask=Highgui.imread("/storage/emulated/0/DCIM/Camera/pokimen.jpg", CvType.CV_8UC1);
Imgproc.grabCut(img, firstMask, rect, bgModel, fgModel, 3, Imgproc.GC_INIT_WITH_MASK);
Core.compare(firstMask, source/* GC_PR_FGD */, firstMask, Core.CMP_EQ);
Log.d("hello", "asdas");
Mat foreground = new Mat(img.size(), CvType.CV_8UC3, new Scalar(255,255, 255));
img.copyTo(foreground, firstMask);
Core.rectangle(img, tl, br, color);
Mat tmp = new Mat();
Imgproc.resize(background, tmp, img.size());
background = tmp;
mask = new Mat(foreground.size(), CvType.CV_8UC1, new Scalar(255, 255, 255));
Imgproc.cvtColor(foreground, mask, 6/* COLOR_BGR2GRAY */);
Imgproc.threshold(mask, mask, 254, 255, 1 /* THRESH_BINARY_INV */);
Mat vals = new Mat(1, 1, CvType.CV_8UC3, new Scalar(0.0));
background.copyTo(dst);
background.setTo(vals, mask);
Core.add(background, foreground, dst, mask);
firstMask.release();
source.release();
bgModel.release();
fgModel.release();
vals.release();
Error:OpenCV Error: Bad argument (mask element value must be equelGC_BGD or GC_FGD or GC_PR_BGD or GC_PR_FGD)
Here is my Image:
Here is my mask :
Please need urgent help.Thanks
5 | retagged |
I want to implement Grabcut using Mask. But its is giving me the assertion error.
Code:
Mat firstMask = new Mat();
Mat bgModel = new Mat();
Mat fgModel = new Mat();
Mat mask;
Mat source = new Mat(1, 1, CvType.CV_8U, new Scalar(3.0));
dst = new Mat();
Rect rect = new Rect(tl, br);
firstMask=Highgui.imread("/storage/emulated/0/DCIM/Camera/pokimen.jpg", CvType.CV_8UC1);
Imgproc.grabCut(img, firstMask, rect, bgModel, fgModel, 3, Imgproc.GC_INIT_WITH_MASK);
Core.compare(firstMask, source/* GC_PR_FGD */, firstMask, Core.CMP_EQ);
Log.d("hello", "asdas");
Mat foreground = new Mat(img.size(), CvType.CV_8UC3, new Scalar(255,255, 255));
img.copyTo(foreground, firstMask);
Core.rectangle(img, tl, br, color);
Mat tmp = new Mat();
Imgproc.resize(background, tmp, img.size());
background = tmp;
mask = new Mat(foreground.size(), CvType.CV_8UC1, new Scalar(255, 255, 255));
Imgproc.cvtColor(foreground, mask, 6/* COLOR_BGR2GRAY */);
Imgproc.threshold(mask, mask, 254, 255, 1 /* THRESH_BINARY_INV */);
Mat vals = new Mat(1, 1, CvType.CV_8UC3, new Scalar(0.0));
background.copyTo(dst);
background.setTo(vals, mask);
Core.add(background, foreground, dst, mask);
firstMask.release();
source.release();
bgModel.release();
fgModel.release();
vals.release();
Error:OpenCV Error: Bad argument (mask element value must be equelGC_BGD or GC_FGD or GC_PR_BGD or GC_PR_FGD)
Here is my Image:
Here is my mask :
Please need urgent help.Thanks