code: def track_points(img1, img2, initial_points=None, gftt_params={}):
      
      params = GFTT_DEFAULTS
      if gftt_params:
          params.update(gftt_params)
  
      if initial_points is None:
          initial_points = cv2.goodFeaturesToTrack(img1, params['max_corners'], params['quality_level'], params['min_distance'])
      
      [_points, status, err] = cv2.calcOpticalFlowPyrLK(img1, img2, initial_points, np.array([]))
  
      # Filter out valid points only
      points = _points[np.nonzero(status)]
      initial_points = initial_points[np.nonzero(status)]
  
      return (points, initial_points)
docs: Track points between two images
      
      Parameters
      -----------------
      img1 : (M, N) ndarray
              First image
      img2 : (M, N) ndarray
              Second image
      initial_points : ndarray
              Initial points. If empty, initial points will be calculated from
              img1 using goodFeaturesToTrack in OpenCV
      gftt_params : dict
              Keyword arguments for goodFeaturesToTrack
      
      Returns
      -----------------
      points : ndarray
              Tracked points
      initial_points : ndarray
              Initial points used