Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mat drawRails(Mat draw, vector<Point>lLines, vector<Point>rLines) {
- //draw rails to the input image
- for (int j = 0; j < lLines.size() - 1; j++) {
- //draw rails - accessing point j and next point to correctly define the line
- line(draw, lLines[j], lLines[j + 1], Scalar(255, 255, 255), 4);
- line(draw, rLines[j], rLines[j + 1], Scalar(255, 255, 255), 4);
- }
- return draw;
- }
- Mat drawHazardLines(Mat draw, vector<Point>lLines, vector<Point>rLines, int frameNum) {
- //draw hazard lines to track
- for (int j = 0; j < lLines.size() - 1; j++) {
- //draw outwards moving rail lines - divide rail width by ten and multiply by modulo 10 of frame to achieve motion
- int railDistNext = (rLines[j + 1].x - lLines[j + 1].x) / 10 * (frameNum % 10) + 2;
- int railDist = (rLines[j].x - lLines[j].x) / 10 * (frameNum % 10) + 2;
- Point Low, High;
- Low = Point(lLines[j].x - railDist, lLines[j].y);
- High = Point(lLines[j + 1].x - railDistNext, lLines[j + 1].y);
- line(draw, Low, High, Scalar(0, 0, 255), 4);
- Low = Point(rLines[j].x + railDist, rLines[j].y);
- High = Point(rLines[j + 1].x + railDistNext, rLines[j + 1].y);
- line(draw, Low, High, Scalar(0, 0, 255), 4);
- }
- return draw;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement