<p>
Photogrammetry is the art of reconstructing digital 3D models using photos.<br />
To reconstruct a 3D model of an object, photos are captured from different angles.
</p>

<h3>Tips for capturing photos</h3>
<ul>
<li>As a general rule in photography:<br />
  The better the illumination, the better the captured photo.</li>
<li>Avoid reflecting surfaces.</li>
<li>For photogrammetry, the scenery and the objects have to stand still.<br />
  Even slight movements of the objects cause distortions.<br />
  Move the camera to obtain photos from different angles.</li>
<li>It is recommended to capture roughly 100 photos of an object.</li>
</ul>

<p>
A set of images can be extracted from a video too. Note that<br />
a set of photos has advantages over a set of extracted images from a video:<br />
Photos contain meta information like focal length and sensor width.<br />
Photos tend to be less blurry.
</p>
<pre><code class="language-bash">ffmpeg -i "$VIDEO" -r "$FPS" -qmin 1 -qscale:v 1 img_%04d.jpg
</code></pre>

<h3>COLMAP</h3>

<p>
Put all photos into a folder called <code>images</code> inside a named project folder:
</p>
<pre><code class="language-bash">PROJECT="my_photogrammetry_experiment"
mkdir -p "$PROJECT/images"
cp *.jpg "$PROJECT/images"
</code></pre>

<p>
Optionally (but highly recommended), create image masks for each image.<br />
Image masks tell colmap where to look for keypoints during feature extraction.<br />
For an image <code>images/0123.jpg</code>, the corresponding mask has to be named <code>masks/0123.jpg.png</code>.<br />
No features will be extracted in regions, where the mask is black (pixel value 0).
</p>

<p>
Execute the reconstruction:
</p>
<pre><code class="language-bash">colmap automatic_reconstructor \
  --workspace_path "$PROJECT" \
  --image_path "$PROJECT/images" \
  --mask_path "$PROJECT/masks"
</code></pre>

<p>
The reconstructed point cloud is written to:
</p>
<pre><code class="langueage-bash">$PROJECT/dense/0/fused.ply
</code></pre>

<p>
The reconstructed mesh is written to:
</p>
<pre><code class="langueage-bash">$PROJECT/dense/0/meshed-poisson.ply
</code></pre>

<h3>MeshLab</h3>

<p>
MeshLab can import point clouds and meshes stored in the Stanford Polygon File Format (*.ply):
</p>
<pre><code class="plaintext">File > Import Mesh...</code></pre>

<p>
Using the point cloud, a mesh can be computed using the following filter:
</p>
<pre><code class="plaintext">Filters > Remeshing, Simplification and Reconstruction > Surface Reconstruction: Screened Poisson
Reconstruction Depth: 12</code></pre>

<p>
There is also a filter for mesh simplification.<br />
The mesh should be smoothed before simplification.
</p>
<pre><code class="plaintext">Filters > Remeshing, Simplification and Reconstruction > Simplification: Quadric Edge Collapse Decimation
Target number of faces</code></pre>

<h3>Blender</h3>

<pre><code class="plaintext">File > Import > Stanford PLY (.ply)
</code></pre>

<p>
<code>Sculpting</code><br />
In the toolbar at the bottom: <code>Smooth</code>
</p>

<h3>External Links</h3>
<ul>
<li><a href="https://colmap.github.io/" target="_blank">
https://colmap.github.io/</a></li>
<li><a href="https://www.meshlab.net/" target="_blank">
https://www.meshlab.net/</a></li>
<li><a href="https://www.blender.org/" target="_blank">
https://www.blender.org/</a></li>
<li><a href="https://www.reddit.com/r/photogrammetry/comments/nlkxfd/colmap_openmvs_is_my_favourite_free_combination/" target="_blank">
https://www.reddit.com/r/photogrammetry/comments/nlkxfd/colmap_openmvs_is_my_favourite_free_combination/</a></li>
</ul>