Fix side detection, add more labels

This commit is contained in:
Yash Karandikar 2023-09-29 11:42:17 -05:00
parent adac66432c
commit ef96235726

View file

@ -9,6 +9,7 @@ import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint; import org.opencv.core.MatOfPoint;
import org.opencv.core.MatOfRect; import org.opencv.core.MatOfRect;
import org.opencv.core.Rect; import org.opencv.core.Rect;
import org.opencv.core.Point;
import org.opencv.core.Scalar; import org.opencv.core.Scalar;
import org.opencv.imgproc.Imgproc; import org.opencv.imgproc.Imgproc;
import org.openftc.easyopencv.OpenCvPipeline; import org.openftc.easyopencv.OpenCvPipeline;
@ -32,7 +33,7 @@ public class FreeSightPipeline extends OpenCvPipeline {
public Scalar lowHSV = new Scalar(0,0,0); public Scalar lowHSV = new Scalar(0,0,0);
public Scalar highHSV = new Scalar(0,0,0); public Scalar highHSV = new Scalar(0,0,0);
public Scalar outline = new Scalar(0,0,0); public Scalar outline = new Scalar(0,255,0);
public Prop colorState = Prop.NONE; public Prop colorState = Prop.NONE;
/** /**
@ -118,7 +119,8 @@ public class FreeSightPipeline extends OpenCvPipeline {
Rect boundingRect = Imgproc.boundingRect(contour); Rect boundingRect = Imgproc.boundingRect(contour);
// center is ( x + w ) / 2 // center is ( x + w ) / 2
int point = (boundingRect.x + boundingRect.width) / 2; // int point = (boundingRect.x + boundingRect.width) / 2;
int point = boundingRect.x + boundingRect.width / 2;
Imgproc.rectangle( Imgproc.rectangle(
threshRGB, threshRGB,
@ -141,6 +143,8 @@ public class FreeSightPipeline extends OpenCvPipeline {
} }
Imgproc.rectangle(threshRGB, new Rect(bigX, 0, width / 3, height), outline); Imgproc.rectangle(threshRGB, new Rect(bigX, 0, width / 3, height), outline);
Imgproc.circle(threshRGB, new Point(boundingRect.x + boundingRect.width / 2, boundingRect.y + boundingRect.height / 2), 10, outline);
Imgproc.putText(threshRGB, positionState.toString(), new Point(boundingRect.x + boundingRect.width / 2, boundingRect.y + boundingRect.height / 2), Imgproc.FONT_ITALIC, 0.5, new Scalar(255, 0, 255));
} }
//list of frames to reduce inconsistency, not too many so that it is still real-time, change the number from 5 if you want //list of frames to reduce inconsistency, not too many so that it is still real-time, change the number from 5 if you want