geohot / twitchslam

A toy implementation of monocular SLAM written while livestreaming
MIT License
959 stars 211 forks source link

ValueError: src.shape[0] must be equal or larger than 8. #15

Open TriniKiskadee opened 1 month ago

TriniKiskadee commented 1 month ago

I keep running into the following error and I'm not sure whats causing it. When I attempting a ransac calculation the following error pops up, and it's not consistent, sometime I can run the code without any errors whatsoever, sometime it's at different time stamps through the video the error will pop up. Any help will be appreciated!!!

/home/runie/.conda/envs/slam/bin/python /home/runie/Desktop/Code/open3d/main.py 
UserWarning: Using SDL2 binaries from pysdl2-dll 2.30.2
/home/runie/.conda/envs/slam/lib/python3.9/site-packages/skimage/measure/fit.py:672: RuntimeWarning: divide by zero encountered in scalar divide
  return np.ceil(np.log(nom) / np.log(denom))
Traceback (most recent call last):
  File "/home/runie/Desktop/Code/open3d/main.py", line 34, in <module>
    main(file=vid)
  File "/home/runie/Desktop/Code/open3d/main.py", line 20, in main
    process_frame(frame)
  File "/home/runie/Desktop/Code/open3d/slam.py", line 56, in process_frame
    idx1, idx2, Rt = match_frames(frames[-1], frames[-2])
  File "/home/runie/Desktop/Code/open3d/frame.py", line 70, in match_frames
    model, inliers = ransac(
  File "/home/runie/.conda/envs/slam/lib/python3.9/site-packages/skimage/_shared/utils.py", line 270, in fixed_func
    return func(*args, **kwargs)
  File "/home/runie/.conda/envs/slam/lib/python3.9/site-packages/skimage/measure/fit.py", line 944, in ransac
    model.estimate(*data_inliers)
  File "/home/runie/.conda/envs/slam/lib/python3.9/site-packages/skimage/transform/_geometric.py", line 529, in estimate
    self._setup_constraint_matrix(src, dst)
  File "/home/runie/.conda/envs/slam/lib/python3.9/site-packages/skimage/transform/_geometric.py", line 319, in _setup_constraint_matrix
    raise ValueError('src.shape[0] must be equal or larger than 8.')
ValueError: src.shape[0] must be equal or larger than 8.

Process finished with exit code 1
Goulustis commented 4 weeks ago

ransac is random so it is not consistent. the code is probably estimating the essential matrix that's required for camera extrinsics. That algorithm needs at least 8 matches inlier. So your image pair probably doesn't have that many