Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. Mat drawRails(Mat draw, vector<Point>lLines, vector<Point>rLines) {
  2. //draw rails to the input image
  3. for (int j = 0; j < lLines.size() - 1; j++) {
  4. //draw rails - accessing point j and next point to correctly define the line
  5. line(draw, lLines[j], lLines[j + 1], Scalar(255, 255, 255), 4);
  6. line(draw, rLines[j], rLines[j + 1], Scalar(255, 255, 255), 4);
  7. }
  8. return draw;
  9. }
  10.  
  11. Mat drawHazardLines(Mat draw, vector<Point>lLines, vector<Point>rLines, int frameNum) {
  12. //draw hazard lines to track
  13. for (int j = 0; j < lLines.size() - 1; j++) {
  14. //draw outwards moving rail lines - divide rail width by ten and multiply by modulo 10 of frame to achieve motion
  15. int railDistNext = (rLines[j + 1].x - lLines[j + 1].x) / 10 * (frameNum % 10) + 2;
  16. int railDist = (rLines[j].x - lLines[j].x) / 10 * (frameNum % 10) + 2;
  17.  
  18.  
  19. Point Low, High;
  20. Low = Point(lLines[j].x - railDist, lLines[j].y);
  21. High = Point(lLines[j + 1].x - railDistNext, lLines[j + 1].y);
  22. line(draw, Low, High, Scalar(0, 0, 255), 4);
  23.  
  24. Low = Point(rLines[j].x + railDist, rLines[j].y);
  25. High = Point(rLines[j + 1].x + railDistNext, rLines[j + 1].y);
  26. line(draw, Low, High, Scalar(0, 0, 255), 4);
  27. }
  28. return draw;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement