Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLOC Returns Random Localization #434

Open
IlanElfen opened this issue Oct 29, 2024 · 0 comments
Open

HLOC Returns Random Localization #434

IlanElfen opened this issue Oct 29, 2024 · 0 comments

Comments

@IlanElfen
Copy link

IlanElfen commented Oct 29, 2024

Hi, I've created a reconstruction model in Metashape and exported it in the sfm format (points3d, images3d, cameras). I've also generated the global-feats-netvlad.h5 and feats-disk.h5.

The camera positions load correctly but the localization seems completely random, even when keeping the camera stationary.
(The camera is currently at (54, 1))
image

Here is the relevant part of my code:

global_descriptor = extract_features.main2(
            model=self.global_model, device=self.device, image=image, gray=False
        )
        pairs = pairs_from_retrieval.main2(
            self.global_db, global_descriptor, self.k, self.global_names
        )
        matches = match_features.main2(
            pairs, local_descriptor, self.local_db, self.matcher, self.device
        )
        cv2.imwrite("tmp.png", cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
        camera = pycolmap.infer_camera_from_image(Path("tmp.png"))
        localizer = QueryLocalizer(self.model, self.conf)
        ret_files = pairs
        self.ref_ids = [self.model.find_image_with_name(n).image_id for n in ret_files]
        ret = pose_from_cluster(
            localizer, local_descriptor, camera, self.ref_ids, matches
        )
        if ret is None:
            return self.ax
        num_inliers = ret["num_inliers"]
        total_correspondences = len(ret["inliers"])
        R = ret["cam_from_world"].rotation.matrix()
        t = ret["cam_from_world"].translation

Any help is greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant