Change crosshair to rectangle

This commit is contained in:
lhark 2016-05-27 19:12:23 +02:00
parent eec5302db0
commit a4b8a05b4d

View file

@ -14,7 +14,7 @@ class Traite_image {
public:
const static int SENSITIVITY_VALUE = 30;
const static int BLUR_SIZE = 10;
const int HORIZONTAL_BORDER_CROP = 20; // In pixels. Crops the border to reduce the black borders from stabilisation being too noticeable.
const int HORIZONTAL_BORDER_CROP = 20; // In pixels. Crops the border to reduce the black borders from stabilisation being too noticeable.
Mat prev;
@ -163,22 +163,15 @@ class Traite_image {
//make a bounding rectangle around the largest contour then find its centroid
//this will be the object's final estimated position.
objectBoundingRectangle = boundingRect(largestContourVec.at(0));
int xpos = objectBoundingRectangle.x+objectBoundingRectangle.width/2;
int ypos = objectBoundingRectangle.y+objectBoundingRectangle.height/2;
//update the objects positions by changing the 'theObject' array values
theObject[0] = xpos , theObject[1] = ypos;
}
//make some temp x and y variables so we dont have to type out so much
int x = theObject[0];
int y = theObject[1];
int x = objectBoundingRectangle.x;
int y = objectBoundingRectangle.y;
int width = objectBoundingRectangle.width;
int height = objectBoundingRectangle.height;
//draw some crosshairs around the object
circle(output,Point(x,y),20,Scalar(0,255,0),2);
line(output,Point(x,y),Point(x,y-25),Scalar(0,255,0),2);
line(output,Point(x,y),Point(x,y+25),Scalar(0,255,0),2);
line(output,Point(x,y),Point(x-25,y),Scalar(0,255,0),2);
line(output,Point(x,y),Point(x+25,y),Scalar(0,255,0),2);
//draw a rectangle around the object
rectangle(output, Point(x,y), Point(x+width, y+height), Scalar(0, 255, 0), 2);
//write the position of the object to the screen
putText(output,"Tracking object at (" + intToString(x)+","+intToString(y)+")",Point(x,y),1,1,Scalar(255,0,0),2);