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:
    1. Starts your Homework 7 node
    2. Starts your Homework 8 node
    3. Runs image_pub_all.py
    4. Starts one rqt_image_view for EACH new topic you create in this assignment (at least the output from canny detection, hough lines on yellow, and hough lines on white).
  3. Update the launcher script for homework 8.

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. You may wish to modify the color parameter in the lines and/or circles to make it clear which line corresponds to which color. Reference: https://docs.opencv.org/3.4/dc/da5/tutorial_py_drawing_functions.html

    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 as described above.. You may create other launch files if you wish, just be sure you specify this one in your submission.

Complete the survey to answer the following:

  • The URL of your repo
  • The git tag for this commit
  • The roslaunch command that starts your assignment.
  • A description of any difficulties you had with this assignment

Rubric

4 points: Submission details (tag, instructions, launcher, etc)

16 points: Correct math/algorithm for image processing

20 points: Correct output images