I'm creating a PapperSoccer project and I have a problem with finding the direction of movement/line. I'm using HoughLinesP
to detect lines and it works as well as possible.
I use ROI
, in which I am looking for a line, and then I move it accordingly.
So far, I used the difference to calculate the direction.
vector<Vec4i> lines;
HoughLinesP(dst, lines, 1, CV_PI / 180, 10, 5, 15);
Vec4i l = lines[i];
roznicax1 = x - (l[0] + abs(xRoi));
roznicax2 = x - (l[2] + abs(xRoi));
roznicay1 = y - (l[1] + abs(yRoi));
roznicay2 = y - (l[3] + abs(yRoi));
Then I have a few conditions which, based on the results, check the direction in which the line goes (north, north-east, south, etc.)
However, the problem arises when I leave the ROI out of the image range. Then these differences are incorrect, and thus - incorrectly determines the direction of the movement.
Can I do it in some other way?