Hello guys I'm new working with OpenCV and I'm trying to implement the grabcut algorithm, well I'm stuck, I've been trying too figured it out how to select the foreground and background with the fine touchups but Im dont know too much python so I cant undestand very well the example. Can anyone here guide me in this process? or at least tell me the steps with the datatype I need?
Here is what i got so far:
Rect selection = new Rect(x1,y1,x2,y2);
Mat mask = new Mat();//(imagen.rows(),imagen.cols(),CvType.CV_8UC1);
Mat cmp = new Mat(1, 1, CvType.CV_8U, new Scalar(3));
Mat foreground;
Mat source = new Mat();
Mat bkground = new Mat();
Mat frground = new Mat();
Imgproc.grabCut(imagen, mask,selection, bkground, frground,5,Imgproc.GC_INIT_WITH_RECT);
Core.compare(mask, cmp,cmp, Core.CMP_EQ);
foreground = new Mat(imagen.size(),CvType.CV_8UC3,new Scalar(150,255,0));
imagen.copyTo(foreground,mask);
Can anyone tell me if I'm in the right way? Also I have to tell you that I've already can select with the touchup the part I want as a foreground, and the one as background, but the point is that I dont know how to apply again the grabcut using the new selection....
Thanks in advance