Fix rectangle colors, attempt to draw rectangle on section

This commit is contained in:
Yash Karandikar 2023-09-29 10:25:49 -05:00
parent e0c1709867
commit adac66432c

View file

@ -97,7 +97,9 @@ public class FreeSightPipeline extends OpenCvPipeline {
Imgproc.findContours(scaledThresh, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);
Mat threshRGB = new Mat();
Imgproc.cvtColor(threshold, threshRGB, Imgproc.COLOR_GRAY2BGR);
if (contours.size() > 0) {
int index = 0;
int area = 0;
for (int i = 0; i < contours.size(); i++)
@ -119,17 +121,27 @@ public class FreeSightPipeline extends OpenCvPipeline {
int point = (boundingRect.x + boundingRect.width) / 2;
Imgproc.rectangle(
threshold,
threshRGB,
boundingRect,
outline
);
if(point < width / 3)
int bigX;
if(point < width / 3) {
positionState = Side.LEFT;
else if(point > width / 1.5)
bigX = 0;
}
else if(point > width / 1.5) {
positionState = Side.RIGHT;
else
bigX = width * 2 / 3;
}
else {
positionState = Side.MIDDLE;
bigX = width / 3;
}
Imgproc.rectangle(threshRGB, new Rect(bigX, 0, width / 3, height), outline);
}
//list of frames to reduce inconsistency, not too many so that it is still real-time, change the number from 5 if you want
if (frameList.size() > 5) {
@ -142,7 +154,8 @@ public class FreeSightPipeline extends OpenCvPipeline {
scaledMask.release();
mat.release();
masked.release();
return threshold;
threshold.release();
return threshRGB;
}
}