(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Building a Database From a Set of Images

Description: This tutorial describes how to create a database for ODUfinder from set of images. The database is stored into binary files, which can than be used by ODUfinder in order to recognize objects.

Keywords: image database, object recognition, SIFT, ODUfinder

Tutorial Level: BEGINNER

Next Tutorial: Detecting Objects http://www.ros.org/wiki/objects_of_daily_use_finder/Tutorials/DetectingObjects

Image Set

The first step is to prepare the images, that will be used to create a database. Put all images in a directory called image_data. It may contain an arbitrary directory tree, since the program will recursively trace all subdirectories and will process all image files found inside. An exception to this rule are only directories named IGNORE and directories starting with a dot (for example /.svn). The supported file formats are those supported by OpenCV : BMP, DIB, JPEG, JPG, JPE, PNG, PBM, PGM, PPM, SR, RAS, TIFF, TIF.

Note: GIF images are not supported!

Parameters

Create a new launch file build_database.launch with a text editor of your choice. The content of the file should look like this:

<launch>
        <node  pkg="objects_of_daily_use_finder" type="odu_finder_node" name="odu_finder" output="screen">
                <param  name="command" type="string" value="/init" />
                <param  name="database_location" type="string" value="<PATH_TO_DATABASE>/" />
                <param  name="images_folder" type="string" value="<PATH_TO_IMAGES>/image_data/" />

                <param  name="tree_k" type="int" value="7" />
                <param  name="tree_levels" type="int" value="7" />
        </node>
</launch>

where <PATH_TO_DATABASE> is a directory where the database files will be saved (the directory should exist) and <PATH_TO_IMAGES> is the path to the previously defined image_data folder.

The parameters tree_k and tree_levels correspond to the K and L parameters of the vocabulary tree as described in D. Nister and H. Stewenius. They define the size of the vocabulary tree and depend on the database images. For small databases (about 200 images) we use values of K=5 and L=5. For the Germandeli database (> 3500 images) we used values of K=7 and L=7.

Building the database

As we now have the launch file ready we just need to start it:

$ roslaunch build_database.launch

The process may take some time, depending on the count of the images in the image set and their sizes. Building the Germandeli database (3500 images) takes about one hour on a normal dual core desktop computer.

Database files

When the process is finished you will find 3 binary files in the database directory specified in the launch file:

  • images.tree - stores the vocabulary tree

  • images.documents - stores the documents of the images (every document is a set of the quantized features of a single image)

  • images.weights - stores the weights of the document vectors computed with TF-IDF algorithm

Those files will be needed to start the detection process. If you also want to visualize the results, you will need the image_data directory too.

Wiki: objects_of_daily_use_finder/Tutorials/BuildingDatabaseFromSetOfImages (last edited 2011-02-25 13:36:56 by MuammerYolga)