Alex-Badea / Pocket-3DR

A MATLAB implementation of a full 3D Reconstruction pipeline for small-scale reconstructions using the functions provided by the Czech Technical University in Prague, Faculty of Electrical Engineering
9 stars 6 forks source link
3d-computer-vision 3d-reconstruction-pipeline bachelor-project matlab multiple-view-geometry photogrammetry structure-from-motion

Pocket 3DR

This is a MATLAB library containing the necessary functions in order to implement a fully functional 3D Reconstruction pipeline. The pipeline runs inside the main.m script file.

The SfM stage of this pipeline is noticeably faster than that of other Photogrammetry programs currently on the market, as it combines background filtering with translation baseline adjustment, which means that, even if it's an incremental SfM pipeline, it doesn't resection the camera every time a new view is added, it just adjusts the global translation within a camera triplet. There is also no need for this process to run within a RANSAC framework, as the background filtering removes many of the outliers still present after correspondence filtering. A small caveat of this library is that the object immortalized needs to be non-Lambertian (the Multi View Stereo stage will fail otherwise), thus the application targets those who want a quick and efficient way to create 3D meshes of small household objects in order to import them in a graphics engine to create video games or CGI.

Installation:

There are no executables available yet. You will need MATLAB in order to run this pipeline.

Usage:

Insert the images of the object to be reconstructed inside the ims folder which will be processed in alphabetical order and provide a calibration file of your camera inside the calib_mats folder. The calibration file needs to have a 3-by-3 matrix K representing the Calibration Matrix and, optionally, a 2-vector d representing the distortion parameters. MATLAB provides a tool that can calibrate the camera for you given some images of a checkerboard pattern as input. The program arguments are the following:

dataset: a common beginning pattern that the images of the object share, e.g. if your images are called mystuff1.jpg, mything2.jpg and myobject3.jpg, the dataset is my;

calib: name of the calibration file;

drp: image pairs used for dense reconstruction, as Multiple View Stereo is a very heavy process and it doesn't need to use all image pairs to provide a dense reconstruction;

threads: if different than 1, will summon that number of MATLAB workers to parallelize all for loops that can run non-deterministically.

These program arguments can be found in the "Program arguments" section of the main.m script. Technically, this is the only section you should adjust to suit your needs, the rest is implementation detail. If you had to modify some parameters other than those in the "Program arguments" section in order for the reconstruction to work, please open an issue!

Examples:

The order is, for each dataset from top to bottom, the following: sparse point cloud → dense point cloud → mesh.

cpl: 47 images

csk: 41 images

mer: 51 images

car: 43 images

+ Dense reconstruction from 2 images
+ High disparity background filtering
+ Dense reconstruction from n>2 images
+ Background cropping for Dense Reconstruction
+ Recoloring
+ Parallel (Multi-core)
- Documentation (Romanian)
- Documentation (English)
- Retexturing
- Background filtering with adaptive bin size (since absolute scale is in relation with translation magnitude)
- Stepwise consistency check (if something goes wrong either let the user fix it or rerun the same block again)
- Parallelize SfM as well