Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Mat OnCameraFrame(CameraBridgeViewBase.ICvCameraViewFrame inputFrame)
- {
- Mat input = inputFrame.Rgba();
- List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
- Mat gray = new Mat();
- //Mat hierarchy = new Mat();
- Imgproc.CvtColor(p0: input, p1: gray, p2: Imgproc.ColorRgb2gray);
- Mat blur = new Mat();
- Imgproc.GaussianBlur(gray, blur, new Size(7, 7), -2);
- Mat thresh = new Mat();
- Imgproc.Threshold(blur, thresh, 127, 250, Imgproc.ThreshBinary);
- Mat edged = new Mat();
- Imgproc.Canny(thresh, thresh, 25, 50);
- Imgproc.Dilate(thresh, thresh, new Mat(), new Point(-1, 1), 1);
- Mat hierarchy = thresh.Clone();
- Imgproc.FindContours(hierarchy, contours, new Mat(),
- Imgproc.RetrExternal, Imgproc.ChainApproxNone);
- Java.Lang.JavaSystem.Out.Println("contours" + contours);
- if (contours != null)
- {
- Java.Lang.JavaSystem.Out.Println("found contours");
- for (int i = 0; i < contours.Count(); i++)
- {
- Imgproc.DrawContours(input, contours, i, new Scalar(255, 0, 0), -1);
- }
- }
- else
- {
- Java.Lang.JavaSystem.Out.Println("no contours");
- }
- return input;
- List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
- IList<MatOfPoint> contours = new JavaList<MatOfPoint>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement