instant-ngp icon indicating copy to clipboard operation
instant-ngp copied to clipboard

colmap2nerf.py NaN problem

Open ralonsoreyes opened this issue 2 years ago • 8 comments

colmap2nerf.py:280: RuntimeWarning: invalid value encountered in true_divide totp /= totw [nan nan nan] avg camera distance from origin nan 111 frames writing transforms.json

[...] "frames": [ { "file_path": "./images/DJI_0353.JPG", "sharpness": 3097.7094803594714, "transform_matrix": [ [ -0.048770823394761034, -0.004720344356321631, 0.9987988411756861, NaN ],

ralonsoreyes avatar Apr 04 '22 11:04 ralonsoreyes

I encountered the same problem while trying to make models from UAV imagery with the Zenmuse X7 camera.

AbrihaDavid avatar Apr 05 '22 07:04 AbrihaDavid

Were you able to solve this issue?

melhashash avatar Apr 28 '22 19:04 melhashash

Not yet

AbrihaDavid avatar Apr 29 '22 06:04 AbrihaDavid

That means your camera poses are not correct

killnice avatar May 24 '22 07:05 killnice

@killnice I think this occurs when the principal rays are parallel to each others, it does not mean that the poses are incorrect.

melhashash avatar May 24 '22 17:05 melhashash

Have the same exact issue when try to test a drone shot, tried a number of ways to solve but nothing does.

sipink avatar Jun 07 '22 15:06 sipink

I have changed two things that made the solver work:

  • changed colmap matcher from exhaustive to sequential,
  • Switched from input of pre-processed images to video input.

This worked in my case.

Kaszanas avatar Jun 18 '22 22:06 Kaszanas

Same issue here,when the principal rays are parallel to each others,we will get Nan,want to know how to slove this.Any suggestions?

lfxx avatar Jun 23 '22 02:06 lfxx

It seems that the problem arises from the closest_point_2_lines(mf[:,3], mf[:,2], mg[:,3], mg[:,2]) in line further if I look closely in the code the w>0.01 is being hardcoded, for the images I was testing the value of w returned from closest_point_2_lines was much lower, perhaps manually setting it to lower value should do the trick to get it up and running, not really sure if that's the correct workaround but does prevent nans from coming. Further, f and g take values from the same set of frames, thus, for the same images in inner loop w will always be zero since the transformation matrices (here and here) will be same so resulting in 0 vector and 0 denom, so perhaps skip those frame indices.

aradhyamathur avatar Aug 15 '22 15:08 aradhyamathur

Thanks to @aradhyamathur , I changed the line w > 0.01 in colmap2nerf.py into w > 0.0001.

Before lowering the threshold, the output:

RuntimeWarning: invalid value encountered in true_divide
  totp /= totw
[nan nan nan]
avg camera distance from origin nan

After lowering the threshold value into 0.0001, the output:

up vector was [-0.99801947 -0.06274485 -0.00449611]
computing center of attention...
[-317.74067482  -24.81560531   -0.35117663]
avg camera distance from origin 318.726712749806

It became non-nan values, and executes without warning.

cjw531 avatar Aug 16 '22 03:08 cjw531

Thanks for pointing this out -- I've pushed a corresponding fix to master

Tom94 avatar Aug 18 '22 05:08 Tom94