본문 바로가기
카테고리 없음

colmap 을 사용 할 수 있는 hloc 도커에서 사용하기

by pulluper 2025. 2. 10.
반응형

 

1) 깃 레포 받기 

git clone --recursive https://github.com/cvg/Hierarchical-Localization/
cd Hierarchical-Localization/

2) 도커 빌드 

docker build . -t hloc:latest

(중 실패 )

 

이슈에서 다음을 찾음 https://github.com/cvg/Hierarchical-Localization/pull/330/commits/f3e43725cba31e75c23c95fdf08722d92c3c2347

 

Update Dockerfile for recent colmap by HelgeS · Pull Request #330 · cvg/Hierarchical-Localization

Dropped Python 3.8 Installed python3-pip This allows the Dockerfile to build with the recent colmap releases. Should fix: Docker image build fails for distutils #320 Docker image build fail #289

github.com

 

docker file 변경후 따라해봄 (+ apt-get install -y git)

FROM colmap/colmap:latest
MAINTAINER Paul-Edouard Sarlin
# ARG PYTHON_VERSION=3.8
# RUN apt-get update -y
# RUN apt-get install -y unzip wget software-properties-common
# RUN add-apt-repository ppa:deadsnakes/ppa && \
#     apt-get -y update && \
#     apt-get install -y python${PYTHON_VERSION}
# RUN wget https://bootstrap.pypa.io/get-pip.py && python${PYTHON_VERSION} get-pip.py
# RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1
RUN apt-get update -y && apt-get install -y unzip wget python3-pip && apt-get install -y git
COPY . /app
WORKDIR app/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install notebook

 

이제야 성공

 

3) 도커 런

docker run -itd --restart always --name hloc -p 8888:8888 -v /mnt/d/data:/usr/src/data hloc:latest /bin/bash

 

4) sfm.py 돌리는데,

hloc > extract_features.py 260 line 쯤에서 다음을 고칩니다. 

 

4-1) num_workers =0, pin_memory=False

 

4-2) sfm.py 에서 if __name__ == "__main__": 코드를 감싼다.

 

from pathlib import Path

from hloc import (
    extract_features,
    match_features,
    reconstruction,
    visualization,
    pairs_from_retrieval,
)

if __name__ == "__main__":


    images = Path("datasets/South-Building/images/")

    outputs = Path("outputs/sfm/")
    sfm_pairs = outputs / "pairs-netvlad.txt"
    sfm_dir = outputs / "sfm_superpoint+superglue"

    retrieval_conf = extract_features.confs["netvlad"]
    feature_conf = extract_features.confs["superpoint_aachen"]
    matcher_conf = match_features.confs["superglue"]

    # if not images.exists():
    #     !unzip -q datasets/South-Building.zip -d datasets/

    retrieval_path = extract_features.main(retrieval_conf, images, outputs)
    pairs_from_retrieval.main(retrieval_path, sfm_pairs, num_matched=5)

    feature_path = extract_features.main(feature_conf, images, outputs)
    match_path = match_features.main(
        matcher_conf, sfm_pairs, feature_conf["output"], outputs
    )

    model = reconstruction.main(sfm_dir, images, sfm_pairs, feature_path, match_path)

    visualization.visualize_sfm_2d(model, images, color_by="visibility", n=5)

 

반응형

댓글