Open AndreAhmed opened 3 years ago
Here is my trial for one mask
depth.copyTo(maskNear);
depth.copyTo(maskFar);
maskNear.convertTo(maskNear, CvType.CV_8U);
Imgproc.cvtColor(maskNear, maskNear, Imgproc.COLOR_BGRA2BGR);
Mat erodeElement = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(4, 4));
Mat dilateElement = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(6, 6));
Imgproc.cvtColor(maskNear, maskNear, Imgproc.COLOR_BGR2GRAY);
Imgproc.threshold(maskNear, maskNear, 0, 180, Imgproc.THRESH_BINARY);
Imgproc.dilate(maskNear, maskNear, erodeElement);
Imgproc.erode(maskNear, maskNear, dilateElement);
convertToGrabCutValues(maskNear);
Mat bgModel = new Mat();
Mat fgModel = new Mat();
Imgproc.grabCut(image, maskNear, new OpenCVForUnity.CoreModule.Rect(), bgModel, fgModel, 5, Imgproc.GC_INIT_WITH_MASK);
convertToGrayScaleValues(maskNear); // back to grayscale values
Imgproc.threshold(maskNear, maskNear, 128, 255, Imgproc.THRESH_TOZERO);
Mat foreground = new Mat(image.size(), CvType.CV_8UC4, new Scalar(0, 0, 0));
image.copyTo(foreground, maskNear);
Utils.fastMatToTexture2D(image, texture);
Hi, I have bought your unity assest. i would like help to create two masks same as the following c++ code.
Please help 👍