Code Monkey home page Code Monkey logo

carla-visual-odometry's Introduction

carla-visual-odometry

What is this?

this is an implementation of visual odometry using stereo camera within CARLA simulator.

How to test?

  1. download the latest carla release from their github repo releases page. I am using the "CARLA_0.9.11.zip" windows release. If you choose the windows release, you just need to unzip the downloaded file.
  2. Run the "WindowsNoEditor\CarlaUE4.exe" file to open the CARLA simulator server.
  3. place the script "stereo_visual_odometry" in the following location "WindowsNoEditor\PythonAPI\examples", and run it.

Results

Screenshots:

result image

Solution Steps

1. Calculating depth using left and right cameras' frames:

  1. Compute disparity of the left frame using opencv's StereoSGBM matcher.
  2. Calculate depth using the focal length, the baseline distance and the calculated disparity map. [depth = Z_c = f*b/d]

2. Extract and match features of each two consecutive frames from the left camera:

  1. Features extraction is done using cv2.goodFeaturesToTrack and ORB describtor.
  2. Matching is done using a brute force matcher. Matches are filtered according to a distance threshold to remove ambigous matches.

3. Motion Estimation:

3D to 2D motion estimation

Using the calculated depth and the matches between the t-1 and t frames the motion is estimated as follows:

  1. Three values are inputed to the cv2.solvePnPRansac() solver:

    • objectpoints: 3D points in camera coordinates.
    • imagepoints: corresponding 2D points pixel values.
    • K: camera intrinsec parameters matrix.

    The solver returns the rotation and the translation vectors.

  2. Get the rotation matrix R from the returned vector using cv2.Rodrigues

4. Update Trajectory

The previously calculated [R|t] matrix are used to calculate the new trajectory point as follow:

RT = np.dot(RT, np.linalg.inv(rt_mtx))

new_trajectory = RT[:3, 3]


References

  • "Visual Perception for Self-Driving Cars" course by university of torronto on Coursera:

    I couldn't have coded this without watching this course first. I even used some of my course-homework code in this.

  • CARLA Simulator Documentation

carla-visual-odometry's People

Contributors

ahmedhisham1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

carla-visual-odometry's Issues

OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'KeyPoint'

y.py
K matrix: [[400. 0. 400.]
[ 0. 400. 300.]
[ 0. 0. 1.]]
world frame: 77489
world frame: 77490


OpenCV(4.6.0) ๐Ÿ‘Ž error: (-5:Bad argument) in function 'KeyPoint'

Overload resolution failed:

  • KeyPoint() missing required argument 'size' (pos 3)

error
127



Finally! Bye!


actor "Actor(id=184, type=vehicle.tesla.model3)" was destroyed!
actor "Actor(id=185, type=sensor.camera.rgb)" was destroyed!
actor "Actor(id=186, type=sensor.camera.rgb)" was destroyed!

I have some error brother, can u help me

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.