This homework will help you learn how to process images (cropping and filtering) in ROS. Our goal in Lab 4 is to create our own lane detector. The first step is to start processing images in ROS using OpenCV. To complete this homework, create a ROS node that:

  1. Subscribes to the “image” topic
  2. Crops the top half out of the received image. The new image should be half as tall as the input image and contain only the bottom half of the input image. This should remove most of the non-lane portion of the image. Feel free to experiment with the exact amount that you crop the image but leave a comment to justify if you choose something besides 50%.
  3. Publishes the new image on a ROS topic called “image_cropped”
  4. Converts this cropped image to HSV (unless you’d rather experiment with other methods)
  5. Filters the image for white pixels such that you can clearly see at least the lane marker on the right of each sample image
  6. Filters the image for yellow pixels such that you can clearly see at least the first dashed marker in the middle of the lane
  7. Optionally, uses erode and/or dilate to improve your results
  8. Publishes BOTH the white and yellow filtered images as the ROS topics “image_white” and “image_yellow” respectively.

Given ROS Package

An example has been included in your repo: the flip_image node in the image_processing_hw package. This example takes an input image on the ROS topic “image” and flips it horizontally. You can use it as a reference when designing your solution for this assignment.

Also uploaded is a helper node, image_pub, in the same package. This node takes in the filename of an image on the command line and publishes it to the “image” topic. On the robot, images will be published by other code, but you can use this to test your code for now. You can see your output using rqt_image_view.

$ rosrun image_processing_hw image_pub.py /code/catkin_ws/src/<REPO>/eece5560/packages/image_processing_hw/sample_images/image0.png

Five sample images have been included in the sample_images folder in the image_processing_hw package. Use them to test your code for this homework.

A launch file has been provided that allows you to start the image_pub node and supply an argument to select which image to show. For example, use this command:

$ roslaunch image_processing_hw image_pub.launch index:=2

To start the node to display the second image (image2.png). This will work for index 0-4.

Submission Instructions

When you submit your code, please include a launch file that starts ONLY your node, 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


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

8 points: Correct math/algorithm for image processing

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