forked from gallant/freesight
fixed it lol
This commit is contained in:
parent
9a45010845
commit
e0c1709867
|
@ -114,24 +114,23 @@ public class FreeSightPipeline extends OpenCvPipeline {
|
||||||
MatOfPoint contour = contours.get(index);
|
MatOfPoint contour = contours.get(index);
|
||||||
|
|
||||||
Rect boundingRect = Imgproc.boundingRect(contour);
|
Rect boundingRect = Imgproc.boundingRect(contour);
|
||||||
int min_x = boundingRect.x;
|
|
||||||
int max_x = boundingRect.x - boundingRect.width;
|
|
||||||
int min_y = boundingRect.y;
|
|
||||||
int max_y = boundingRect.y - boundingRect.height;
|
|
||||||
|
|
||||||
// center is ( x + w ) / 2
|
// center is ( x + w ) / 2
|
||||||
|
|
||||||
|
int point = (boundingRect.x + boundingRect.width) / 2;
|
||||||
|
|
||||||
Imgproc.rectangle(
|
Imgproc.rectangle(
|
||||||
threshold,
|
threshold,
|
||||||
new Rect(
|
boundingRect,
|
||||||
min_x,
|
|
||||||
min_y,
|
|
||||||
boundingRect.width,
|
|
||||||
boundingRect.height
|
|
||||||
),
|
|
||||||
outline
|
outline
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(point < width / 3)
|
||||||
|
positionState = Side.LEFT;
|
||||||
|
else if(point > width / 1.5)
|
||||||
|
positionState = Side.RIGHT;
|
||||||
|
else
|
||||||
|
positionState = Side.MIDDLE;
|
||||||
|
|
||||||
//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
|
||||||
if (frameList.size() > 5) {
|
if (frameList.size() > 5) {
|
||||||
frameList.remove(0);
|
frameList.remove(0);
|
||||||
|
|
Loading…
Reference in a new issue