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

Not handling all NERF formats #19

Open
mmoyes opened this issue Jan 23, 2024 · 1 comment
Open

Not handling all NERF formats #19

mmoyes opened this issue Jan 23, 2024 · 1 comment

Comments

@mmoyes
Copy link

mmoyes commented Jan 23, 2024

I get the following error

  File "/home/m/work/aos/camorph/m.py", line 4, in <module>
    cams = camorph.read_cameras('nerf',r'/home/m/work/aos/nerfdata/take15_optimized_cams/transforms.json')
  File "/home/m/work/aos/camorph/camorph/camorph.py", line 29, in read_cameras
    cams = src_inst.read_file(*args, **kwargs)
  File "/home/m/work/aos/camorph/camorph/ext/NeRF/NeRF.py", line 144, in read_file
    cam.focal_length_px = [.5 * cam.resolution[0] / np.tan(.5 * camera_angle_x),
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

for code

import camorph.camorph as camorph
cams = camorph.read_cameras('nerf',r'/home/m/work/aos/nerfdata/take15_optimized_cams/transforms.json')
camorph.visualize(cams)

It seems camera_angle_x is not being set. Possibly because transforms.json is using a matrix instead;

{
    "camera_model": "OPENCV",
    "frames": [
        {
            "file_path": "images/frame_00001.jpg",
            "w": 3000,
            "h": 4088,
            "fl_x": 10716.10907946319,
            "fl_y": 10716.10907946319,
            "cx": 1381.2775952841873,
            "cy": 2280.181297884072,
            "k1": 0.0971299736922087,
            "k2": -7.007934572579263,
            "k3": 130.90033135432077,
            "k4": 0.0,
            "p1": -0.0024336328994766076,
            "p2": 0.0065866252174946885,
            "transform_matrix": [
                [
                    -0.3353805106176828,
                    0.3177818535863063,
                    -0.8868678631166393,
                    -6.4681681952398336
                ],
                [
                    -0.9415249266924297,
                    -0.08067195141513692,
                    0.3271434680254041,
                    2.4909429428524836
                ],
                [
                    0.032414896492773564,
                    0.944725743158365,
                    0.326255336660165,
                    4.375235441944789
                ],
                [
                    0.0,
                    -0.0,
                    -0.0,
                    1.0
                ]
            ]
        },

...
@bbrand-iis
Copy link
Collaborator

Hey mmoyes,

Where did you get this .json file? The problem with this format is that the intrinsics are directly part of the frames array and not global. If you want to handle individual intrinsics, the individual intrinsics need to be under a seperate attribute called "intrinsics" like so:

{
    "camera_model": "OPENCV",
    "frames": [
        {
            "file_path": "images/frame_00001.jpg",
            "intrinsics": {
                "w": 3000,
                "h": 4088,
                "fl_x": 10716.10907946319,
                "fl_y": 10716.10907946319,
                "cx": 1381.2775952841873,
                "cy": 2280.181297884072,
                "k1": 0.0971299736922087,
                "k2": -7.007934572579263,
                "k3": 130.90033135432077,
                "k4": 0.0,
                "p1": -0.0024336328994766076,
                "p2": 0.0065866252174946885
            },
            "transform_matrix": [
                [
                    -0.3353805106176828,
                    0.3177818535863063,
                    -0.8868678631166393,
                    -6.4681681952398336
                ],
                [
                    -0.9415249266924297,
                    -0.08067195141513692,
                    0.3271434680254041,
                    2.4909429428524836
                ],
                [
                    0.032414896492773564,
                    0.944725743158365,
                    0.326255336660165,
                    4.375235441944789
                ],
                [
                    0.0,
                    -0.0,
                    -0.0,
                    1.0
                ]
            ]
        }]
}

Additionally I pushed some changes that should fix the bug you encountered.

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

2 participants