geohot / twitchslam

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

ValueError: ndarray is not C-contiguous #9

Open robelkebede opened 5 years ago

robelkebede commented 5 years ago

frame 2/628 Matches: 1581 -> 1581 -> 1215 -> 1214 Culled: 0 points Pose: 0.022129 Traceback (most recent call last): File "./slam.py", line 218, in slam.process_frame(frame, None if gt_pose is None else np.linalg.inv(gt_pose[i])) File "./slam.py", line 86, in process_frame for m_idx in f1.kd.query_ball_point(projs[i], 2): File "ckdtree.pyx", line 910, in scipy.spatial.ckdtree.cKDTree.query_ball_point File "stringsource", line 654, in View.MemoryView.memoryview_cwrapper File "stringsource", line 349, in View.MemoryView.memoryview.cinit ValueError: ndarray is not C-contiguous

VibAltekar commented 4 years ago

@robelkebede44

in slam.py add

projs = projs.copy(order='C')

on line 77 after the good_pts declaration

Will look something like this:

` projs = projs[:, 0:2] / projs[:, 2:]

  # only the points that fit in the frame
  good_pts = (projs[:, 0] > 0) & (projs[:, 0] < self.W) & \
             (projs[:, 1] > 0) & (projs[:, 1] < self.H)
  projs = projs.copy(order='C')   
  for i, p in enumerate(self.mapp.points):
    if not good_pts[i]:
      # point not visible in frame
      continue`