Skip to content

Running 'mesh' command with Brown-Conrady camera model raises an exception #259

Description

@fester

I was trying to set up BrownPerspectiveCamera for a testing project and ended up having exception while executing a 'mesh' command.

Traceback (most recent call last):
  File "./bin/opensfm", line 34, in <module>
    command.run(args)
  File "/home/fester/dev/sfm/OpenSfM/opensfm/commands/mesh.py", line 28, in run
    data)
  File "/home/fester/dev/sfm/OpenSfM/opensfm/mesh.py", line 20, in triangle_mesh
    return triangle_mesh_perspective(shot_id, r, graph)
  File "/home/fester/dev/sfm/OpenSfM/opensfm/mesh.py", line 66, in triangle_mesh_perspective
    vertices[i] = back_project_no_distortion(shot, pixels[i], d).tolist()
  File "/home/fester/dev/sfm/OpenSfM/opensfm/mesh.py", line 76, in back_project_no_distortion
    p = np.array([pixel[0], pixel[1], shot.camera.focal])
AttributeError: 'BrownPerspectiveCamera' object has no attribute 'focal'

Content of camera_models.json follows:

{
    "v2 unknown unknown 3840 2160 perspective 0": {
        "p2": -0.0008835724792082445, 
        "focal_x_prior": 0.695010239026, 
        "p1": -0.0010691942590595035, 
        "p1_prior": 0.0021613899529269866, 
        "k2": -0.018579862045926137, 
        "k2_prior": -0.018579862045926137, 
        "k3_prior": 0.0021613899529269866, 
        "projection_type": "brown", 
        "c_x_prior": 0.498615992893, 
        "height": 2160, 
        "k3": 0.019389890813014215, 
        "width": 3840, 
        "k1": 0.0021613899529269866, 
        "c_y_prior": 0.499767087292, 
        "focal_y": 1.23557375827, 
        "focal_x": 0.695010239026, 
        "p2_prior": -0.018579862045926137, 
        "c_y": 0.499767087292, 
        "c_x": 0.498615992893, 
        "focal_y_prior": 1.23557375827, 
        "k1_prior": 0.0021613899529269866
    }

It seems that Delaunay mesh reconstruction doesn't account for the new camera model.
Unfortunately I'm not familiar with the topic well enough to contribute a patch. Could you please consider fixing this issue or maybe recommend a (temporary) solution, i.e. use commands.undistort.perspective_camera_from_brown before calling back_project_no_distortion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions