Git Product home page Git Product logo

lanecv's Introduction

LaneCV

Airport taxiway lane detection with OpenCV-Python. A part of WPI's ACAP (Autonomous Cargo Aircraft Project), completed 2016-2017 by Nicholas Bradford (view the MQP report here).

Processing pipeline screenshot

/lanecv
    demo.py                 Demo code
    lanes.py                laneDetection() and helpers
    fit.py                  fitLines() and helpers
    model.py                MultiModel and LineModel
    particlefilter.py       MetaModel and ParticleFilterModel
    communicate.py          ZMQ messaging
    util.py                 Misc utilities, mainly wrappers used across modules
    config.py               Constants such as image size
    plotter.py              Helpful plotting functions
    /proto                  Protobuf files
        lanecv.proto        Protocol definition file
        lanecv_pb2.py       Python file generated from lanecv.proto
    archive.py              Old code archived away
/test                       Unit tests
/media                      Footage for testing
requirements.txt            Install with $ python install -r 
runner.py                   Run tests and a demo.

Usage

Requirements

Note that you'll need OpenCV compiled with FFMPEG support in order to load videos. Use this script and some tutorials to understand:

Then to finish, activate your new cv virtual environment and install the other requirements:

$ workon cv 
$ pip install -r requirements.txt

Demo

Run a demo:

$ python runner.py   

Protobuf compilation

After modifying the lanecv.proto definition, use protoc to recompile the python and java files.

$ cd ./lanecv/proto
$ protoc -I=. --python_out=. lanecv.proto
$ protoc -I=. --java_out=.  lanecv.proto 

Overview

Initialize by creating a MetaModel, perspectiveMatrix, and backgroundSubtractor. Open the video, and for each frame, update the metamodel state using the results of laneDetection(). A MetaModel is composed of two ParticleFilterModel instances, each of which track a single LineModel. The MetaModel receives updates in the form of a MultiModel (two LineModel instances).

Algorithm

  1. Apply perspective transform to Region of Interest (ROI)
  2. Update N-frame (2-frame) background model
  3. Extract background to eliminate propeller motion
  4. Extract yellow color
  5. Dilate and erode
  6. Apply morphological skeleton procedure to extract “centers” of lanes
  7. Predict if there are multiple lanes using covariance matrix eigenvalues
  8. Use sequential RANSAC to fit up to two lines to data
  9. Update particle filtering models with RANSAC hypotheses
  10. Return particle filter estimates

Assumptions

  • Each lane can be approximated as a single line in form [offset, orientation] from the nose of the plane.
  • There will never be more than 2 lanes in a single frame (could be changed by adding another step to fitLines() and extending the MetaModel).
  • The runway is a flat surface (used for perspective transform).
  • The taxiway lane markings are clearly defined yellow.
  • The plane motion is reasonably slow (required for background subtraction of the properller, as well as proper particle filtering).

TODO

Priorities

Exploration

  • Build model with prior distribution given Airport model
  • Fit complex B-snake/spline/curve to yellow-extraction
    • Need to define search space...

Backlog

  • Model particle motion as a moving average of the previous changes; or as plane motion forward; or as plane motion towards the center line.
  • Two-way ZMQ-Protobuf integration
  • Optimize to reduce needless image copying
  • Increase dilation and increase resolution
  • Perspective Transform: widen field, expand upwards to horizon
  • Try using ridges/edges instead of color (fails under extreme curves)
  • Video Stabilization with Visual Odometry (hard)

lanecv's People

Contributors

nsbradford avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

merkurt

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.