Code Monkey home page Code Monkey logo

ros-road-line-junction-extraction's Introduction

3D road line extraction, bird's-eye view projection, and junction detection for ROS stereo images

Finds the middle line of a road, and its junctions, in a stereo image. Tested with ROS+Gazebo (DRC Atlas robot), but should work with any stereo camera as input.

A Convolutional Neural Network, CN24, is used for road detection. Subsequently, a birds-eye view is calculated using OpenCV's findHomography and warpPerspective. Line segments are obtained by thinning the detected road, simplifying with a voxel grid filter, and calculating a minimum spanning tree of the resulting points.

Usage

Requires:

  • CN24 - the environment variable 'CN24PATH' has to be set to the path to the cn24 build directory (e.g. 'export CN24PATH=/home/USER/cn24/build')
  • numpy, scipy, matplotlib
  • skimage
  • cv2
  • pcl (optional)
  • ROS and rospy to capture image data (optional)

Usage example:

import matplotlib
import matplotlib.pyplot as plt
from roadlinesegments import *

## uncomment to obtain images from ROS topic
#from savesensordata_node import *
#import time
#savesensordata()
#time.sleep(2)

## load images
camimg = getcameraimg()
roadimg = getroadimg()
depthmap, points, notnanindices = getdepthimg()

## get birds-eye view
warpedimg, H = getbirdseyeview(camimg, roadimg, depthmap, points, notnanindices)

## run road detection   
points, edge_list, junctionpointidx, allpoints = getroadlinesegments(camimg, warpedimg, H)

## plot results
plt.subplot(1,2,1)
camimg[roadimg!=0] += [0,100,0] # paint road green for visualization
plt.imshow(camimg)
plt.title("Original image and road detection")

plt.subplot(1,2,2)
plt.imshow(warpedimg)
for edge in edge_list:
    plt.plot([points[edge[0], 0], points[edge[1], 0]], [points[edge[0], 1], points[edge[1], 1]], c='r')
for i in junctionpointidx:
    plt.scatter(points[i, 0], points[i, 1], c='red', s=300)
plt.title('Birds-eye warped image, road skeleton and junctions')
plt.show()

Examples

Detected road in first-person camera image (left), obtained by a simulated robot, and the same image warped to bird's eye perspective (right) Example 1

Actual environment Example 1

Detected road in first-person camera image (left), obtained by a simulated robot, and the same image warped to bird's eye perspective (right) Example 1

Actual environment Example 1

ros-road-line-junction-extraction's People

Contributors

thrillseeker avatar tmadl avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.