adds code to detect edges
authorEvanYap <evanyap.14@gmail.com>
Tue, 15 Nov 2016 04:00:23 +0000 (20:00 -0800)
committerEvanYap <evanyap.14@gmail.com>
Tue, 15 Nov 2016 04:00:23 +0000 (20:00 -0800)
IsolateImage.java

index 5768d5b786d2a539e1bcdf51f06f660f7c5e1f6c..18b76a2c11c9908f6b6066e8171e63b161d66176 100644 (file)
@@ -38,6 +38,26 @@ public class IsolateImage {
                processImage();
        }
 
+       public static void findContours() {
+
+               ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
+               int frameCount = 0;
+               int THE_BEST_MAGIC_NUMBER = 300;
+
+               contours.clear();
+               matOriginal = Imgcodecs.imread("imgs/goal2.png"); // convert image
+               // into matrix
+
+               filtered = matOriginal;
+
+               // bing bing bong bong
+               // bing bing bong bong
+               Imgproc.cvtColor(matOriginal, filtered, Imgproc.COLOR_BGR2GRAY);
+               Imgproc.GaussianBlur(matOriginal, filtered, new Size(5, 5), Core.BORDER_DEFAULT);
+               Imgproc.Canny(matOriginal, filtered, 35, 125);
+
+       }
+
        public static void processImage() {
 
                ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
@@ -45,7 +65,7 @@ public class IsolateImage {
                int THE_BEST_MAGIC_NUMBER = 300;
                while (frameCount < 1) {
                        contours.clear();
-                       matOriginal = Imgcodecs.imread("imgs/goal.png"); // convert image
+                       matOriginal = Imgcodecs.imread("imgs/goal2.png"); // convert image
                        // into matrix
 
                        filtered = matOriginal;
@@ -61,7 +81,7 @@ public class IsolateImage {
                                MatOfPoint matOfPoint = iterator.next();
                                Rect rec = Imgproc.boundingRect(matOfPoint);
                                if (rec.height < THE_BEST_MAGIC_NUMBER || rec.width < THE_BEST_MAGIC_NUMBER) {
-                                       System.out.println(rec.toString());
+
                                        iterator.remove();
                                }
 
@@ -70,13 +90,13 @@ public class IsolateImage {
                        for (MatOfPoint mop : contours) {
                                Rect rec = Imgproc.boundingRect(mop);
                                Imgproc.rectangle(matOriginal, rec.br(), rec.tl(), GRAY, 1);
+                               System.out.println(rec.toString());
                        }
 
                        frameCount++;
                }
 
                Imgcodecs.imwrite("output.png", filtered);
-               System.out.println("done");
 
        }