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>();
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;
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();
}
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");
}