Database Format

COLMAP stores all extracted information in a single SQLite database file. Thedatabase can be accessed with the database management toolkit in the COLMAP GUI,the provided C++ database API (seesrc/colmap/scene/database.h), or usingPython with pycolmap.

The database contains the following tables:

  • rigs

  • cameras

  • frames

  • images

  • keypoints

  • descriptors

  • matches

  • two_view_geometries

To initialize an empty SQLite database file with the required schema, you caneither create a new project in the GUI or executesrc/colmap/exe/database_create.cc.

Rigs and Sensors

The relation between rigs and sensors (cameras, etc.) is 1-to-N with one sensorbeing chosen as the reference sensor to define the origin of the rig. Each sensormust only be part of one rig.

Rigs and Frames

The relation between rigs and frames is 1-to-N, where a frame defines a specificinstance of the rig with all or a subset of sensors exposed at the same time.

Cameras and Images

The relation between cameras and images is 1-to-N. This has importantimplications for Structure-from-Motion, since one camera shares the sameintrinsic parameters (focal length, principal point, distortion, etc.), whileevery image has separate extrinsic parameters (orientation and location).

The intrinsic parameters of cameras are stored as contiguous binary blobs infloat64, ordered as specified insrc/colmap/sensor/models.h. COLMAP onlyuses cameras that are referenced by images, all other cameras are ignored.

Thename column in the images table is the unique relative path in the imagefolder. As such, the database file and image folder can be moved to differentlocations, as long as the relative folder structure is preserved.

When manually inserting images and cameras into the database, make surethat all identifiers are positive and non-zero, i.e.image_id>0andcamera_id>0.

Keypoints and Descriptors

The detected keypoints are stored as row-majorfloat32 binary blobs, where thefirst two columns are the X and Y locations in the image, respectively. COLMAPuses the convention that the upper left image corner has coordinate(0,0) andthe center of the upper left most pixel has coordinate(0.5,0.5). If thekeypoints have 4 columns, then the feature geometry is a similarity and thethird column is the scale and the fourth column the orientation of the feature(according to SIFT conventions). If the keypoints have 6 columns, then thefeature geometry is an affinity and the last 4 columns encode its affine shape(seesrc/feature/types.h for details).

The extracted descriptors are stored as row-majoruint8 binary blobs, whereeach row describes the feature appearance of the corresponding entry in thekeypoints table. Note that COLMAP only supports 128-D descriptors for now, i.e.thecols column must be 128.

In both tables, therows table specifies the number of detected features perimage, whilerows=0 means that an image has no features. For feature matchingand geometric verification, every image must have a corresponding keypoints anddescriptors entry. Note that only vocabulary tree matching with fast spatialverification requires meaningful values for the local feature geometry, i.e.,only X and Y must be provided and the other keypoint columns can be set to zero.The rest of the reconstruction pipeline only uses the keypoint locations.

Matches and two-view geometries

Feature matching stores its output in thematches table and geometricverification in thetwo_view_geometries table. COLMAP only uses the data intwo_view_geometries for reconstruction. Every entry in the two tables storesthe feature matches between two unique images, where thepair_id is therow-major, linear index in the upper-triangular match matrix, generated asfollows:

defimage_ids_to_pair_id(image_id1,image_id2):ifimage_id1>image_id2:return2147483647*image_id2+image_id1else:return2147483647*image_id1+image_id2

and image identifiers can be uniquely determined from thepair_id as:

defpair_id_to_image_ids(pair_id):image_id2=pair_id%2147483647image_id1=(pair_id-image_id2)/2147483647returnimage_id1,image_id2

Thepair_id enables efficient database queries, as the matches tables maycontain several hundred millions of entries. This scheme limits the maximumnumber of images in a database to 2147483647 (maximum value of signed 32-bitintegers), i.e.image_id must be smaller than 2147483647.

The binary blobs in the matches tables are row-majoruint32 matrices, wherethe left column are zero-based indices into the features ofimage_id1 and thesecond column into the features ofimage_id2. The columncols must be 2 andtherows column specifies the number of feature matches.

The F, E, H blobs in thetwo_view_geometries table are stored as 3x3 matricesin row-majorfloat64 format. The meaning of theconfig values are documentedin thesrc/estimators/two_view_geometry.h source file.