Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public Mat OnCameraFrame(CameraBridgeViewBase.ICvCameraViewFrame inputFrame)
  2. {
  3. Mat input = inputFrame.Rgba();
  4. List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
  5. Mat gray = new Mat();
  6. //Mat hierarchy = new Mat();
  7. Imgproc.CvtColor(p0: input, p1: gray, p2: Imgproc.ColorRgb2gray);
  8. Mat blur = new Mat();
  9. Imgproc.GaussianBlur(gray, blur, new Size(7, 7), -2);
  10. Mat thresh = new Mat();
  11. Imgproc.Threshold(blur, thresh, 127, 250, Imgproc.ThreshBinary);
  12. Mat edged = new Mat();
  13. Imgproc.Canny(thresh, thresh, 25, 50);
  14. Imgproc.Dilate(thresh, thresh, new Mat(), new Point(-1, 1), 1);
  15. Mat hierarchy = thresh.Clone();
  16. Imgproc.FindContours(hierarchy, contours, new Mat(),
  17. Imgproc.RetrExternal, Imgproc.ChainApproxNone);
  18. Java.Lang.JavaSystem.Out.Println("contours" + contours);
  19. if (contours != null)
  20. {
  21. Java.Lang.JavaSystem.Out.Println("found contours");
  22. for (int i = 0; i < contours.Count(); i++)
  23. {
  24. Imgproc.DrawContours(input, contours, i, new Scalar(255, 0, 0), -1);
  25. }
  26.  
  27. }
  28. else
  29. {
  30. Java.Lang.JavaSystem.Out.Println("no contours");
  31. }
  32. return input;
  33.  
  34. List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
  35.  
  36. IList<MatOfPoint> contours = new JavaList<MatOfPoint>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement