Robot Line Following

A program to detect and track lines in real-time with Hough Transform using C++ and OpenCV library. A drone robot is assigned to follow the line with given points and directions and choose the right path in intersections with existing QR codes.

Step-by-Step solution

  • Capturing real-time frame stream by opening the camera
  • Applying preliminary filters to the stream (such as resizing to 160 x 120, reducing noise)
  • Filtering the image by the color
  • Detecting lines of each frame with Hough transform
  • Checking if there is an intersection to make a decision
  • Emitting signals containing the direction and position of the line found


  • C++ Programming Language (version >=11)
  • OpenCV (version 2.4.13 is preferred)
  • Opencv-Zbar
  • Qextserialport
  • QR creator



There is a continues line with some intersections on the ground. In each intersection there is a QR code that shows the next direction. Robot is assinged to detect and track the line. In this case, the algorithm return the center position of the detected line to adjust itself to the center and be stable.