Skip to content

Commit

Permalink
Merge branch 'master' into new-shtik-for-wrist
Browse files Browse the repository at this point in the history
  • Loading branch information
greenblitz4590 committed Jun 23, 2024
2 parents 4ccb659 + 37495ac commit a55024b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);

Expand Down

0 comments on commit a55024b

Please sign in to comment.