diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/vision/PropProcessor.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/vision/PropProcessor.java index 3b623a2..92cb159 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/vision/PropProcessor.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/vision/PropProcessor.java @@ -22,43 +22,43 @@ public void init(int width, int height, CameraCalibration calibration) { @Override public Object processFrame(Mat frame, long captureTimeNanos) { - Mat leftZone = getLeftZoneMatrix(frame); + Mat rightZone = getRightZoneMatrix(frame); Mat centerZone = getCenterZoneMatrix(frame); - Scalar left = getAvgColor(leftZone); - Scalar center = getAvgColor(centerZone); + Scalar avgRightColor = getAvgColor(rightZone); + Scalar avgCenterColor = getAvgColor(centerZone); - if (isPropPartOfAvgColor(left)) { - this.location = PropLocation.LEFT; + if (isPropPartOfAvgColor(avgRightColor)) { + this.location = PropLocation.RIGHT; } - else if (isPropPartOfAvgColor(center)) { + else if (isPropPartOfAvgColor(avgCenterColor)) { this.location = PropLocation.CENTER; } else { - this.location = PropLocation.RIGHT; + this.location = PropLocation.LEFT; } - leftZone.release(); + rightZone.release(); centerZone.release(); return null; } - public Mat getLeftZoneMatrix(Mat frame) { + public Mat getRightZoneMatrix(Mat frame) { if (Robot.getInstance().getAlliance() == Alliance.RED) { - return frame.submat(VisionConstant.RED_LEFT_ZONE_AREA); + return frame.submat(VisionConstant.RED_RIGHT_ZONE); } else { - return frame.submat(VisionConstant.BLUE_LEFT_ZONE_AREA); + return frame.submat(VisionConstant.BLUE_RIGHT_ZONE); } } public Mat getCenterZoneMatrix(Mat frame) { if (Robot.getInstance().getAlliance() == Alliance.RED) { - return frame.submat(VisionConstant.RED_CENTER_ZONE_AREA); + return frame.submat(VisionConstant.RED_CENTER_ZONE); } else { - return frame.submat(VisionConstant.BLUE_CENTER_ZONE_AREA); + return frame.submat(VisionConstant.BLUE_CENTER_ZONE); } } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/vision/VisionConstant.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/vision/VisionConstant.java index 89b942b..ddcfd16 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/vision/VisionConstant.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/vision/VisionConstant.java @@ -2,7 +2,6 @@ import org.firstinspires.ftc.vision.VisionPortal; import org.opencv.core.Rect; -import org.opencv.core.Scalar; import org.opencv.core.Size; class VisionConstant { @@ -22,10 +21,10 @@ class VisionConstant { protected static final double RED_THRESHOLD = 100; protected static final double AMOUNT_OF_COLOR = 2.8; - protected static final Rect RED_LEFT_ZONE_AREA = new Rect(0, 330, 100, 150); - protected static final Rect RED_CENTER_ZONE_AREA = new Rect(320, 330, 320, 150); - protected static final Rect BLUE_LEFT_ZONE_AREA = new Rect(0, 330, 320, 150); - protected static final Rect BLUE_CENTER_ZONE_AREA = new Rect(380, 330, 100, 150); + protected static final Rect RED_RIGHT_ZONE = new Rect(400, 400, 100, 80); + protected static final Rect RED_CENTER_ZONE = new Rect(20, 330, 80, 150); + protected static final Rect BLUE_RIGHT_ZONE = new Rect(400, 400, 100, 80); + protected static final Rect BLUE_CENTER_ZONE = new Rect(20, 330, 80, 150); protected static final Size BLUR_SIZE = new Size(5, 5);