Colmap docker imageLink
As we want the possibility to choose the Python version we use, for example 3.8, and the provided docker image are based on Ubuntu 18.04 that ship Python 3.6 & 3.7, we need to create our own Dockerfile
.
This has been done in docker/colmap/Dockerfile
with:
- Python 3.8
- Colmap 3.7
Build the docker imageLink
To build the docker image, use the Dockerfile
in docker/colmap/
:
image_name="roboticsmicrofarms/colmap"
image_version="3.7"
docker build -t="$image_name:$image_version" docker/colmap/.
docker tag "$image_name:$image_version" "$image_name:latest"
Test the containerLink
Let's test the image we just created!
Start a containerLink
You can start by creating a running container with:
docker run -it --gpus all \
-v /tmp/integration_tests/2019-02-01_10-56-33/:/tmp/ \
roboticsmicrofarms/colmap:3.7
Try to call the colmap executable to get the version number with:
colmap -v
As we also installed Python, try to call it after activating the venv
with:
. /venv/bin/activate
python -V
Get a test datasetLink
To further test the built image, let's try to use colmap on a typical set of data. If you do not have your own dataset, we provide a test dataset that you can download (to the temporary folder) as follows:
cd /tmp
wget https://db.romi-project.eu/models/test_db.tar.gz
tar -xf test_db.tar.gz
Extract images posesLink
We use the "poses" (camera locations) provided in the images' metadata (JSON file associated to each images) by the plant-imager to create a poses.txt
file containing each image coordinates:
import os
import json
posefile = open(f"/tmp/poses.txt", mode='w')
# - Try to get the pose from each file metadata:
for i, file in enumerate(sorted(os.listdir("/tmp/metadata/images"))):
with open(f"/tmp/metadata/images/{file}", mode='r') as f:
jdict = json.load(f)
# print(jdict)
try:
p = jdict['approximate_pose']
except KeyError:
p = jdict['pose'] # backward compatibility, should work for provided test dataset
s = '%s %d %d %d\n' % (file.split('.')[0] + ".jpg", p[0], p[1], p[2])
posefile.write(s)
posefile.close()
Test colmap toolsLink
You can test that the colmap tools are working properly by calling them as follows:
DATASET_PATH=/tmp
colmap feature_extractor \
--database_path $DATASET_PATH/database.db \
--image_path $DATASET_PATH/images
colmap exhaustive_matcher \
--database_path $DATASET_PATH/database.db
mkdir $DATASET_PATH/sparse
colmap mapper \
--database_path $DATASET_PATH/database.db \
--image_path $DATASET_PATH/images \
--output_path $DATASET_PATH/sparse
colmap model_aligner \
--ref_images_path $DATASET_PATH/poses.txt \
--input_path $DATASET_PATH/sparse/0 \
--output_path $DATASET_PATH/sparse/0 \
--ref_is_gps 0 \
--robust_alignment_max_error 10
colmap model_converter \
--input_path $DATASET_PATH/sparse/0 \
--output_path $DATASET_PATH/sparse/0/sparse.ply \
--output_type PLY
mkdir $DATASET_PATH/dense
colmap image_undistorter \
--image_path $DATASET_PATH/images \
--input_path $DATASET_PATH/sparse/0 \
--output_path $DATASET_PATH/dense \
--output_type COLMAP \
--max_image_size 2000
colmap patch_match_stereo \
--workspace_path $DATASET_PATH/dense \
--workspace_format COLMAP \
--PatchMatchStereo.geom_consistency true
colmap stereo_fusion \
--workspace_path $DATASET_PATH/dense \
--workspace_format COLMAP \
--input_type geometric \
--output_path $DATASET_PATH/dense/fused.ply
Test geometric pipelineLink
If you have plant-3d-vision
installed on your machine, you can further test the colmap image with the reconstruction pipelines using our test scripts and datasets.
Test it on real dataLink
export COLMAP_EXE="roboticsmicrofarms/colmap"
./tests/check_geom_pipe.sh --tmp
Test it on virtual dataLink
export COLMAP_EXE="roboticsmicrofarms/colmap"
./tests/check_geom_pipe.sh --tmp --virtual
Test it on your (real) dataLink
export COLMAP_EXE="roboticsmicrofarms/colmap"
./tests/check_geom_pipe.sh --tmp --database /path/to/my/dataset
Upload the built imageLink
Once you have checked the obtained image leads to functional containers, you can upload the image to docker hub!
Start by login in to docker hub with:
docker login
Then you can upload with:
docker push "$image_name"