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

How to define initial camera params #55

Open
rlamarche opened this issue Mar 22, 2024 · 3 comments
Open

How to define initial camera params #55

rlamarche opened this issue Mar 22, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@rlamarche
Copy link

Hi,

First thank you for this awesome project !

I wonder if it is possible to set initial camera params in the cameras.yaml file ?
For example, if I define an OPENCV camera model, can I set initial fx, fy, cx,cy, k1, k2, p1 and p2 params ?

If they are guessed, how are they guessed ?

Do I need to manually update them in the database.db colmap file ? Because the column type is a blob and it might not be easy to do it on command line.

Thank you.

@lcmrl
Copy link
Collaborator

lcmrl commented Mar 23, 2024

Hi, I am working to add this option directly in cameras.yaml, for now you can open database.db with COLMAP GUI and modify there the camera params or, not elegant but simple, silmply go to the function create_camera() in src/deep_image_matching/io/h5_to_db.py:

def create_camera(db: Path, image_path: Path, camera_model: str):
    image = Image.open(image_path)
    width, height = image.size

    focal = get_focal(image_path)

    if camera_model == "simple-pinhole":
        model = 0  # simple pinhole
        param_arr = np.array([focal, width / 2, height / 2])
    elif camera_model == "pinhole":
        model = 1  # pinhole
        param_arr = np.array([focal, focal, width / 2, height / 2])
    elif camera_model == "simple-radial":
        model = 2  # simple radial
        param_arr = np.array([focal, width / 2, height / 2, 0.1])
    elif camera_model == "opencv":
        model = 4  # opencv
        param_arr = np.array([focal, focal, width / 2, height / 2, 0.0, 0.0, 0.0, 0.0])
    else:
        raise RuntimeError(f"Invalid camera model {camera_model}")

    return db.add_camera(model, width, height, param_arr)

The 4 last params in OPENCV camera model are k1, k2, p1 and p2. You can substitute zeros with your values.
Thanks for the feedback, I will let you know when the new features will be added. Feel free to open an issue if you find any problem or to collaborate!

@lcmrl lcmrl self-assigned this Mar 23, 2024
@lcmrl lcmrl added the enhancement New feature or request label Mar 23, 2024
@rlamarche
Copy link
Author

Thank you for your feedback ! I did not find how to change using colmap gui, but I'm glad it's possible.

Also, thank you for pointing out how to change it in the code.

Keep going, your work is awesome. I'm trying the feature detection & matching on very low quality underwater datasets and I'm convinced that it can make a huge difference.

Regards,

Romain.

@oUp2Uo
Copy link

oUp2Uo commented Mar 25, 2024

Thank you for your feedback ! I did not find how to change using colmap gui, but I'm glad it's possible.

Also, thank you for pointing out how to change it in the code.

Keep going, your work is awesome. I'm trying the feature detection & matching on very low quality underwater datasets and I'm convinced that it can make a huge difference.

Regards,

Romain.

In COLMAP UI, (Processing - Database Management), you could change the camera model or initial parameters.

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

No branches or pull requests

3 participants