Objectives

In this assignment, you will finish your lane detector using edge detection and Hough transforms. This will then make the core of your code for Lab 3. You will take in the result of Homework 7 and output new images showing the outlines of the lane markers. To do this:

  1. Create a ROS node (or multiple nodes if you prefer) that:
    1. Subscribes to the cropped image from Homework 7
    2. Performs Canny edge detection on the cropped image. You may use a different method if you find it works better. Publish this (for debug/grading purposes) to the topic “image_edges”.
    3. Subscribes to the white and yellow filtered images from Homework 7
    4. Combines the result of edge detection with EACH of the filtered images using the OpenCV bitwise_and operator. This will produce an image composed of just the boundaries of the white and yellow markers. If not, refine your filter and/or edge detector. You may need to tune your erode/dilate steps from Homework 7 to do this. You may modify your Homework 7 code to accomplish this.
    5. Performs a Hough transform on each of the images resulting from step 1d.
    6. Draws lines found in the Hough transform on the cropped image from Homework 7 for each of the above. This should produce one color image with lines on it for the white lane markers and one color image with lines on it for yellow lane markers. Publish these two images as “image_lines_white” and “image_lines_yellow”
    7. Optionally, combines the white and yellow line images into one image and make an “image_lines_all” topic.
  2. Create a launch file that runs each of the nodes in this pipeline (so Homework 7 and homework 8). REQUIRED: do NOT include image_pub or rqt_image_view in this launch file.

Test on each image given in the sample images folder. You want your line detector to find the longest straight-line segments possible. Tune your parameters for filtering, edge detection, and Hough transform until this happens. Some tips are below. Feel free to modify any of these tips as you like as long as you get a good result and produce the desired images. You may wish to go back to prior steps and blur or erode/dilate to improve results.

Tips

Your ROS node requires input from multiple topics. There are many ways to do this. The simplest way is to store each message you receive from Homework 7 and run processing once you receive all of the inputs you expect. Think about what to expect first/last and how often you expect messages to arrive.

Below is a Python function that will take in an image and a set of lines (the output from the cv2.houghp function) and return an image with the lines drawn on. Feel free to use this code to generate your final image for this assignment.

    def output_lines(self, original_image, lines):
        output = np.copy(original_image)
        if lines is not None:
            for i in range(len(lines)):
                l = lines[i][0]
                cv2.line(output, (l[0],l[1]), (l[2],l[3]), (255,0,0), 2, cv2.LINE_AA)
                cv2.circle(output, (l[0],l[1]), 2, (0,255,0))
                cv2.circle(output, (l[2],l[3]), 2, (0,0,255))
        return output

Submission Instructions

When you submit your code, please include a launch file that starts ONLY your nodes, not the image_pub or rqt_image_view nodes. You may create other launch files if you wish, just be sure you specify this one in your submission.

Turn in to blackboard one PDF containing:

  • The URL of your repo
  • The git tag for this commit
  • The roslaunch command that starts just your node (not image_pub or rqt_image_view)
  • Both the white and yellow output image for each sample images (10 images total)
  • A description of any difficulties you had with this assignment

Rubric

2 points: Submission details (tag, instructions, etc)

18 points: Correct math/algorithm for image processing

20 points: Correct output images (submitted to Blackboard and from running code)