Skip to content

Commit

Permalink
Support for RGB-D cameras (live SLAM, saving sequences) + small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
strasdat committed Dec 12, 2011
1 parent fbaa5c2 commit 39305bf
Show file tree
Hide file tree
Showing 17 changed files with 618 additions and 39 deletions.
143 changes: 136 additions & 7 deletions README
Expand Up @@ -209,17 +209,13 @@ Move to main project folder "ScaViSLAM" and install ScaViSLAM:
cd ../../../
mkdir svs_build
cd svs_build
<<

In case you would like to compile ScaViSLAM WITHOUT CUDA support, open
"../src/CMakeLists.txt" using your favourite editor and change
"SET(CUDA_SUPPORT ON)" --> "SET(CUDA_SUPPORT OFF)".

>>
cmake ../src
make -j8
<<

In case you would like to compile ScaViSLAM WITHOUT CUDA support, type
"cmake -DCUDA_SUPPORT=OFF ../src/" instaed of "cmake ../src"

Make sure the "New College" data set is downloaded completely.
Then add a sym-link inside "ScaViSLAM/data":

Expand All @@ -233,3 +229,136 @@ Run ScaViSLAM on new college image sequence:
cd ../svs_build
./stereo_slam ../data/newcollege.cfg
<<


*** How to use a camera live ***

At the moment, only RGB-D cameras following the PrimeSense reference design
(e.g. Ausus Xtion PRO LIVE) are supported.
First, you need to install PCL (which includes OpenNI):

>>
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-all
<<

Reinstall ScaViSLAM with PCL support:

>>
cd MY_SOFTWARE_DIRECTORY
cd /ScaViSLAM/
mkdir svs_build_with_pcl
cd svs_build_with_pcl
cmake -DCUDA_SUPPORT=ON ..
make -j8
>>

Try out ScaViSLAM with your RGB-D camera life:

>>
./stereo_slam ../data/rgbd-Live.cfg
<<

To dump RGBD data to the hard disk (to ../data/out; create this directory or
set approriate sym-link.).:

>>
./dump_rgbd ../data/rgbd_live.cfg
<<

Finally, you can process the saved image sequence by adapting the configuration
files "../data/rgbd_example.cfg". Basically, you have to point
"framepipe.path_str" to the saved images.


*** What about standard stereo cameras ? ***

This is more tricky since we need to make sure that the image stream is
rectified. Some adaptation in the code might be necessary.


*** How to contribute? ***

You are welcome to report bugs and request features at:
https://github.com/strasdat/ScaViSLAM/issues.
To do so click on "New Issue", fill out the form and select the approriate
label ("Bug" or "Feature Request").
Please feel free to also browse through the "ToDo" and "Future Features"
issues, so you can find out which features are planned to be included
soon ("ToDo") or eventually ("Future Features").

The best and easiest way to contribute is to use the "github" way:
- Register at github (for free).
- Got to: "https://github.com/strasdat/ScaViSLAM"
- Click on "Fork" to create a Fork of ScaViSLAM.
- Commit and push changes into your Fork.
- Click on "Pull Request" in order to ask me whether I would like to merge
the changes into the ScaViSLAM master branch.

(If it is only a small change/bug fix, you could also simply send me
patch etc.)

In order to maximize the likelyhood that I will accept your pull request,
please read carefully thourgh the coding style guide:


*** Coding Style Guide ***

The coding style is largely influenced by the google c++ coding style guide:
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
(Reading the document is insightful in any case, even if you don't agree with
"google's" decision!)

I am especially strick about the following rules:

- "When defining a function, parameter order is: inputs, then outputs."
- "All parameters passed by reference must be labeled const."
Thus, the following is NOT okay:
'void method(const Vector2d & in, Vector2d & out)'
Use this instead:
'void method(const Vector2d & in, Vector2d * out)'
- "Of the built-in C++ integer types, the only one used is int. If a program
needs a variable of a different size, use a precise-width integer type
from <stdint.h>, such as int16_t."
- "Use 0 for integers, 0.0 for reals, NULL for pointers, and '\0' for chars."
- "We do not use C++ exceptions."
- "Use the specified order of declarations within a class: public: before
private:, methods before data members (variables), etc."
- "Use a struct only for passive objects that carry data; everything else
is a class."
- "Prefer small and focused functions."
- "Use only approved libraries and language extensions from C++11 (formerly
known as C++0x). Currently, none are approved."
- "We do not allow default function parameters, except in a few uncommon
situations..."
- "Use prefix form (++i) of the increment and decrement operators with
iterators and other template objects."
- "We strongly recommend that you use const whenever it makes sense to do so."

At some points, I deviate from the C++ coding style guide:
- 'Using namespace X;' is okay, but only within(!) the ScaViSLAM namespace.
Never pollute the general namespace '::'.
(However, do not use "using namespace cv" or 'using namespace pangolin'.)
- I use 'boost::thread'.
- In rare cases, it is okay to habe public class members.
- It is okay to use streams such as "cout", "cerr", "stringstream". (But
usually, I'd like to use "cerr" and friends only for debugging purposes...)

I also deviate slightly from google's formating. Therefore the following rule
is the most important one:

"Use common sense and BE CONSISTENT.

If you are editing code, take a few minutes to look at the code around you and
determine its style. If they use spaces around their if clauses, you should,
too. If their comments have little boxes of stars around them, make your
comments have little boxes of stars around them too."

(All cites in "quatation marks" are from the google coding style guide.)

If you would like to use automatic identation, I recommend you to use
the standard setting in QtCreator 1.3.1 (or newer), however with
"Tools/Options/Text Editor/Behavior/Indent size = 2" and a maximal number of
80 characters per line (i.e. mark
"Tools/Options/Text Editor/Display/Display right margin at column = 80").
56 changes: 56 additions & 0 deletions data/rgbd_example.cfg
@@ -0,0 +1,56 @@

cam.dist_right1 = 0;
cam.dist_right2 = 0;
cam.dist_right3 = 0;
cam.dist_right4 = 0;
cam.dist_right5 = 0;

cam.dist_left1 = 0;
cam.dist_left2 = 0;
cam.dist_left3 = 0;
cam.dist_left4 = 0;
cam.dist_left5 = 0;




cam.rotx_right = 0;
cam.roty_right = 0;
cam.rotz_right = 0;

cam.rotx_left = 0;
cam.roty_left = 0;
cam.rotz_left = 0;







cam.width = 640;
cam.height = 480;
cam.f = 591.52441444;
cam.px = 320;
cam.py = 240;
cam.baseline = 0.07468;
framepipe.skip_imgs = 100;
framepipe.livestream = 0;
framepipe.mask_img = 0;
framepipe.disp_img = 1;
framepipe.right_img = 0;
framepipe.color_img = 0;
framepipe.format_str = png;
framepipe.path_str = ../data/example;
framepipe.base_str = .*rgbd.*;
frontend.save_dense_cloud = 1;
frontend.new_keyframe_featureless_corners_thr = 2;
frontend.new_keyframe_pixel_thr = 70;
frontend.newpoint_clearance = 2;
frontend.num_frames_metric_loop_check = 50;
frontend.covis_thr = 10;
graph.outer_window = 100;
graph.inner_window = 7;
use_n_levels_in_frontent = 3;
ui.parallax_thr = 0.15
ui.max_reproj_error = 3
52 changes: 52 additions & 0 deletions data/rgbd_live.cfg
@@ -0,0 +1,52 @@

cam.dist_right1 = 0;
cam.dist_right2 = 0;
cam.dist_right3 = 0;
cam.dist_right4 = 0;
cam.dist_right5 = 0;

cam.dist_left1 = 0;
cam.dist_left2 = 0;
cam.dist_left3 = 0;
cam.dist_left4 = 0;
cam.dist_left5 = 0;




cam.rotx_right = 0;
cam.roty_right = 0;
cam.rotz_right = 0;

cam.rotx_left = 0;
cam.roty_left = 0;
cam.rotz_left = 0;







cam.width = 640;
cam.height = 480;
cam.f = 591.52441444;
cam.px = 320;
cam.py = 240;
cam.baseline = 0.07468;
framepipe.livestream = 1;
framepipe.mask_img = 0;
framepipe.disp_img = 1;
framepipe.right_img = 0;
framepipe.color_img = 1;
frontend.save_dense_cloud = 1;
frontend.new_keyframe_featureless_corners_thr = 2;
frontend.new_keyframe_pixel_thr = 70;
frontend.newpoint_clearance = 2;
frontend.num_frames_metric_loop_check = 50;
frontend.covis_thr = 15;
graph.outer_window = 100;
graph.inner_window = 15;
use_n_levels_in_frontent = 3;
ui.parallax_thr = 0.15
ui.max_reproj_error = 3
14 changes: 12 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -7,14 +7,21 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}

SET (CMAKE_VERBOSE_MAKEFILE ON)

SET(CUDA_SUPPORT ON)
SET(PCL_SUPPORT OFF)
IF( NOT CUDA_SUPPORT )
SET(CUDA_SUPPORT ON)
ENDIF()

IF( NOT PCL_SUPPORT )
SET(PCL_SUPPORT OFF)
ENDIF()

IF(CUDA_SUPPORT)
MESSAGE ("CUDA SUPPORT ON")
ADD_DEFINITIONS(-DSCAVISLAM_CUDA_SUPPORT)
ENDIF()

IF(PCL_SUPPORT)
MESSAGE ("PCL SUPPORT ON")
ADD_DEFINITIONS(-DSCAVISLAM_PCL_SUPPORT)
FIND_PACKAGE(PCL 1.2 REQUIRED)
ADD_DEFINITIONS(${PCL_DEFINITIONS})
Expand Down Expand Up @@ -146,5 +153,8 @@ ELSE()
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCES})
ENDIF()
ADD_EXECUTABLE(create_dictionary create_dictionary.cpp)
IF(PCL_SUPPORT)
ADD_EXECUTABLE(dump_rgbd dump_rgbd.cpp)
ENDIF()

INCLUDE_DIRECTORIES(${INCLUDE_DIRS} ${PCL_INCLUDE_DIRS})
10 changes: 5 additions & 5 deletions src/create_dictionary.cpp
Expand Up @@ -164,13 +164,13 @@ calculateWordsAndSaveThem(int TARGET_NUM_WORDS,
distance());
cout << "Done: dictionary of " << num_centers << " words created!" << endl;
assert(sizeof(float)==4);
cv::Mat centers_floats_as_4uchars(num_centers,
descriptors.cols*4,
CV_8U,
centers.data);
cv::Mat centers_float_as_four_uint8(num_centers,
descriptors.cols*4,
CV_8U,
centers.data);
stringstream str_stream;
str_stream<< "surfwords" << num_centers << ".png";
cv::imwrite(str_stream.str(), centers_floats_as_4uchars);
cv::imwrite(str_stream.str(), centers_float_as_four_uint8);

cout << "Saved as file: " << str_stream.str() << endl;
}
Expand Down

0 comments on commit 39305bf

Please sign in to comment.