Visual SLAM (with OpenCV)

SLAM = Simultaneous Locationing And Mapping

OpenCV = a free programming library, which give you easy access to your webcam and it also includes lots of image-processing algorithms which are useful for AI.

SLAM = You keep track of your own position on a map, without knowing what the map looks like in advance. So you explore and build the map from scratch, while at the same time keeping track of where you are in the map.

Visual = You do all this using nothing more than a videocamera. Just like living creatures. No radar, no laser, no beacons, no compass.

There are lots of examples of “visual SLAM” on YouTube. Below you can see one example created by Robert Sim.

This is state-of-the-art AI technology, but you can build it yourself using the OpenCV library which gives you alot of sourcecode for free! You could build a small robot which drives around and creates a map of the environment, and figures out where it is! (but microcontrollers are too weak to do the processing – you need a fast computer. Maybe put a laptop on wheels?)

A much simpler idea, but which is still very similar, is to create a stereo-camera and use that as a very accurate distance-sensor! This will be very useful for a system which need to accurately know how far away something is.

Infra-red distance sensor: very inaccurate data, max distance 1 meter.

Ultrasound sensor: very inaccurate data, max distance 5 meters.

Visual stereocamera: extremely accurate data, max distance ~50 meters.

The idea is to use more than one camera, at least two, and then try to find the same point in both images. Depending on where the point is in the images, you can calculate the distance by simple trigonometry that you learnt in high-school. If you only need to find a single point, then you could put a LED there so it is very easy to find in the image. If you want to read the distance to many points at once, then it is probably better to use a “distinguisable-point”-algorithm. The “FAST” feature transform is such a thing, and it is included in the OpenCV library so you don’t have to write it yourself. Also, OpenCV makes it really easy to read the image from your webcam and process it in whatever way you want. Any project which need to use a webcam will probably benefit alot from using OpenCV.

– Patrik Nordquist, Group T


2 responses to “Visual SLAM (with OpenCV)

  1. FFT comes from fast Fourier transform, not feature. Anyway, very good post for SLAM newbies. Keep it up 😀

  2. Please, can you explain me how to do SLAM using OpenCV library?? I want to map my house in a 3d model.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s