Cleanup unused imports

This commit is contained in:
Scott Barnes 2024-02-21 17:44:55 -06:00
parent 0c57500e30
commit b491568e6c
5 changed files with 1 additions and 33 deletions

View File

@ -5,7 +5,6 @@
So it won't ultimately be as empty as it might here appear to be :-) --> So it won't ultimately be as empty as it might here appear to be :-) -->
<!-- The package name here determines the package for your R class and your BuildConfig class --> <!-- The package name here determines the package for your R class and your BuildConfig class -->
<manifest <manifest>
xmlns:android="http://schemas.android.com/apk/res/android">
<application/> <application/>
</manifest> </manifest>

View File

@ -1,7 +1,6 @@
package com.tearabite.ftctearabits.vision; package com.tearabite.ftctearabits.vision;
import static com.tearabite.ftctearabits.graphics.LinePaint.WHITE; import static com.tearabite.ftctearabits.graphics.LinePaint.WHITE;
import static com.tearabite.ftctearabits.vision.Detection.PropertyScale.Pixels;
import static com.tearabite.ftctearabits.vision.FTCColors.FTC_BLUE_RANGE; import static com.tearabite.ftctearabits.vision.FTCColors.FTC_BLUE_RANGE;
import static com.tearabite.ftctearabits.vision.FTCColors.FTC_RED_RANGE_1; import static com.tearabite.ftctearabits.vision.FTCColors.FTC_RED_RANGE_1;
import static com.tearabite.ftctearabits.vision.FTCColors.FTC_RED_RANGE_2; import static com.tearabite.ftctearabits.vision.FTCColors.FTC_RED_RANGE_2;

View File

@ -1,15 +0,0 @@
package com.tearabite.ftctearabits.vision;
import org.opencv.core.Scalar;
public class Constants {
public static Scalar RED = new Scalar(255, 0, 0);
public static Scalar GREEN = new Scalar(0, 255, 0);
public static Scalar BLUE = new Scalar(0, 0, 255);
public static Scalar WHITE = new Scalar(255, 255, 255);
public static Scalar GRAY = new Scalar(80, 80, 80);
public static Scalar BLACK = new Scalar(0, 0, 0);
public static Scalar ORANGE = new Scalar(255, 165, 0);
public static Scalar YELLOW = new Scalar(255, 255, 0);
public static Scalar PURPLE = new Scalar(128, 0, 128);
}

View File

@ -1,7 +1,5 @@
package com.tearabite.ftctearabits.vision; package com.tearabite.ftctearabits.vision;
import android.graphics.Color;
import org.opencv.core.Scalar; import org.opencv.core.Scalar;
public class FTCColors { public class FTCColors {
public static Scalar FTC_RED_LOWER = new Scalar(165, 80, 80); public static Scalar FTC_RED_LOWER = new Scalar(165, 80, 80);

View File

@ -12,54 +12,43 @@ import org.opencv.imgproc.Moments;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
// CV Helper Functions
public class OpenCVUtil { public class OpenCVUtil {
public static String telem = "nothing";
// Draw a point
public static void drawPoint(Mat img, Point point, Scalar color) { public static void drawPoint(Mat img, Point point, Scalar color) {
Imgproc.circle(img, point, 3, color, -1); Imgproc.circle(img, point, 3, color, -1);
} }
// Get the center of a contour
public static Point getCenterOfContour(MatOfPoint contour) { public static Point getCenterOfContour(MatOfPoint contour) {
Moments moments = Imgproc.moments(contour); Moments moments = Imgproc.moments(contour);
return new Point(moments.m10 / moments.m00, moments.m01/ moments.m00); return new Point(moments.m10 / moments.m00, moments.m01/ moments.m00);
} }
// Get the bottom left of a contour
public static Point getBottomLeftOfContour(MatOfPoint contour) { public static Point getBottomLeftOfContour(MatOfPoint contour) {
Rect boundingRect = Imgproc.boundingRect(contour); Rect boundingRect = Imgproc.boundingRect(contour);
return new Point(boundingRect.x, boundingRect.y+boundingRect.height); return new Point(boundingRect.x, boundingRect.y+boundingRect.height);
} }
// Get the bottom right of a contour
public static Point getBottomRightOfContour(MatOfPoint contour) { public static Point getBottomRightOfContour(MatOfPoint contour) {
Rect boundingRect = Imgproc.boundingRect(contour); Rect boundingRect = Imgproc.boundingRect(contour);
return new Point(boundingRect.x+boundingRect.width, boundingRect.y+boundingRect.height); return new Point(boundingRect.x+boundingRect.width, boundingRect.y+boundingRect.height);
} }
// Draw a contour
public static void drawContour(Mat img, MatOfPoint contour, Scalar color) { public static void drawContour(Mat img, MatOfPoint contour, Scalar color) {
Imgproc.drawContours(img, Collections.singletonList(contour), 0, color, 2); Imgproc.drawContours(img, Collections.singletonList(contour), 0, color, 2);
} }
// Draw a convex hull around a contour
public static void drawConvexHull(Mat img, MatOfPoint contour, Scalar color) { public static void drawConvexHull(Mat img, MatOfPoint contour, Scalar color) {
MatOfInt hull = new MatOfInt(); MatOfInt hull = new MatOfInt();
Imgproc.convexHull(contour, hull); Imgproc.convexHull(contour, hull);
Imgproc.drawContours(img, Collections.singletonList(convertIndexesToPoints(contour, hull)), 0, color, 2); Imgproc.drawContours(img, Collections.singletonList(convertIndexesToPoints(contour, hull)), 0, color, 2);
} }
// Draw a filled in convex hull around a contour
public static void fillConvexHull(Mat img, MatOfPoint contour, Scalar color) { public static void fillConvexHull(Mat img, MatOfPoint contour, Scalar color) {
MatOfInt hull = new MatOfInt(); MatOfInt hull = new MatOfInt();
Imgproc.convexHull(contour, hull); Imgproc.convexHull(contour, hull);
Imgproc.drawContours(img, Collections.singletonList(convertIndexesToPoints(contour, hull)), 0, color, -1); Imgproc.drawContours(img, Collections.singletonList(convertIndexesToPoints(contour, hull)), 0, color, -1);
} }
// Convert indexes to points that is used in order to draw the contours
public static MatOfPoint convertIndexesToPoints(MatOfPoint contour, MatOfInt indexes) { public static MatOfPoint convertIndexesToPoints(MatOfPoint contour, MatOfInt indexes) {
int[] arrIndex = indexes.toArray(); int[] arrIndex = indexes.toArray();
Point[] arrContour = contour.toArray(); Point[] arrContour = contour.toArray();
@ -74,7 +63,6 @@ public class OpenCVUtil {
return hull; return hull;
} }
// Get the largest contour out of a list
public static MatOfPoint getLargestContour(List<MatOfPoint> contours) { public static MatOfPoint getLargestContour(List<MatOfPoint> contours) {
if (contours.size() == 0) { if (contours.size() == 0) {
return null; return null;
@ -82,7 +70,6 @@ public class OpenCVUtil {
return getLargestContours(contours, 1).get(0); return getLargestContours(contours, 1).get(0);
} }
// Get the top largest contours
public static List<MatOfPoint> getLargestContours(List<MatOfPoint> contours, int numContours) { public static List<MatOfPoint> getLargestContours(List<MatOfPoint> contours, int numContours) {
Collections.sort(contours, (a, b) -> (int) Imgproc.contourArea(b) - (int) Imgproc.contourArea(a)); Collections.sort(contours, (a, b) -> (int) Imgproc.contourArea(b) - (int) Imgproc.contourArea(a));
return contours.subList(0, Math.min(numContours, contours.size())); return contours.subList(0, Math.min(numContours, contours.size()));