Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

IndexError: _Map_base::at when runing pycolmap.triangulate_points #289

@bowieshi

Description

@bowieshi

Hi. I am using hloc triangulation to reconstruct my scene when I have camera ground truth pose and images. I first use rec.add_camera(camera), rec.add_image(img), rec.register_image(image_id) to build the rec. I have set img attribute cam_from_world = pycolmap.Rigid3d(pycolmap.Rotation3d(qvec), tvec) with ground truth pose. Then I export them using rec.write(export_dir / 'reference_model'). I got 3 .bin file and I tried using colmap model_converter --output_type TXT to .bin. And I got 3 .txt file. I found my image information looks complete, like following:

# Camera list with one line of data per camera:
#   CAMERA_ID, MODEL, WIDTH, HEIGHT, PARAMS[]
# Number of cameras: 1
0 SIMPLE_PINHOLE 640 480 500.23599999999999 318.72800000000001 240.06800000000001
# Image list with two lines of data per image:
#   IMAGE_ID, QW, QX, QY, QZ, TX, TY, TZ, CAMERA_ID, NAME
#   POINTS2D[] as (X, Y, POINT3D_ID)
# Number of images: 2163, mean observations per image: 0
1108 0.34782986433108698 0.077406669808001469 0.93358963585906773 0.037854785234972349 -2.65252 0.16404199999999999 -0.65826300000000004 0 frame_001108.png

1107 0.33061990066509883 0.080584875788237018 0.94003671756553597 0.022967993099255912 -2.6674899999999999 0.15226100000000001 -0.668041 0 frame_001107.png

1106 0.32005393416087918 0.085187182475924828 0.94354280590137418 0.0059662887726593377 -2.6869499999999999 0.096220100000000003 -0.68079999999999996 0 frame_001106.png

1105 0.30174095045953364 0.091024885055342175 0.94845684428035271 -0.0331131945634058 -2.6903100000000002 0.087598800000000004 -0.70806999999999998 0 frame_001105.png

1104 0.29772088183921863 0.093955062710698853 0.94858562352113918 -0.052153979300897851 -2.6884399999999999 0.070330500000000004 -0.71776899999999999 0 frame_001104.png

1103 0.29673592636449936 0.095477876307010393 0.94715776496126702 -0.07565668122567204 -2.6871 0.047271599999999997 -0.72970100000000004 0 frame_001103.png

1102 0.2921759087227922 0.095757770084796134 0.94689770418444541 -0.094066070613291461 -2.6898900000000001 0.026290299999999999 -0.73790500000000003 0 frame_001102.png

1101 0.29041503705016386 0.093835911971266894 0.94590712067561733 -0.11006201404133788 -2.69685 0.0075736500000000003 -0.74869799999999997 0 frame_001101.png

1100 0.28803302007224268 0.089337106225661489 0.94450006581965695 -0.13029000907955859 -2.6995399999999998 -0.016844600000000001 -0.75598399999999999 0 frame_001100.png

......
......
......
# 3D point list with one line of data per point:
#   POINT3D_ID, X, Y, Z, R, G, B, ERROR, TRACK[] as (IMAGE_ID, POINT2D_IDX)
# Number of points: 0, mean track length: 0

Then, I use the following code to reconstruct my scene under ground truth poses:

def get_reconstruct(images_dir, export_dir):
    # extract global features for retrieval
    feature_conf = extract_features.confs["netvlad"]
    global_features_path = extract_features.main(
        conf=feature_conf, 
        image_dir=images_dir, 
        export_dir=export_dir
    )

    pairs_path = export_dir / 'pairs.txt'
    pairs_from_retrieval.main(
        descriptors=global_features_path, 
        query_prefix="frame",
        db_prefix="frame",
        output=pairs_path,
        num_matched=20,
    )

    # extract local features for reconstruction
    feature_conf = extract_features.confs["superpoint_max"]
    local_features_path = extract_features.main(
        conf=feature_conf, 
        image_dir=images_dir, 
        export_dir=export_dir
    )
    match_conf = match_features.confs["superglue"]
    match_path = match_features.main(
        conf=match_conf,
        pairs=pairs_path, 
        features=feature_conf['output'], 
        features_ref=local_features_path,
        export_dir=export_dir
    )
    reconstruction = triangulation.main(
        sfm_dir=export_dir / 'sfm', 
        reference_model=export_dir / 'reference_model', 
        image_dir=images_dir, 
        pairs=pairs_path, 
        features=local_features_path,
        matches=match_path
    )
    return reconstruction

However, I got strange error when run pycolmap.triangulate_points:

Traceback (most recent call last):
  File "/home/qyzheng/boao/project/scripts/camera_localize.py", line 158, in <module>
    reconstruction = get_reconstruct(reference_images_dir, export_dir)
  File "/home/qyzheng/boao/project/scripts/camera_localize.py", line 96, in get_reconstruct
    reconstruction = triangulation.main(
  File "/home/qyzheng/boao/project/Hierarchical-Localization/hloc/triangulation.py", line 256, in main
    reconstruction = run_triangulation(
  File "/home/qyzheng/boao/project/Hierarchical-Localization/hloc/triangulation.py", line 211, in run_triangulation
    reconstruction = pycolmap.triangulate_points(
IndexError: _Map_base::at

Can I inquire whether I missed something? I looked through all issues but can not find similar problem. I have stuck here for several days. If you can help, many thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions