def __call__(self, img1, img2, pt1, pt2=None, thresh=2.0, return_msk=False):
    '\n        Arguments:\n            img1(np.ndarray) : previous image. (color/mono) (HxWx?)\n            img2(np.ndarray) : current image (color/mono) (HxWx?)\n            pt1(np.ndarray)  : previous points. (Mx2)\n            pt2(np.ndarray)  : [Optional] current points estimate (Mx2)\n            thresh(float)    : Flow Back-projection Error threshold\n\n        Returns:\n            pt2(np.ndarray)  : current points. (Mx2)\n            idx(np.ndarray)  : valid tracked indices from pt1 & pt2.\n        '
    if (pt1.size <= 0):
        pt2 = np.empty([0, 2], dtype=np.float32)
        if return_msk:
            msk = np.empty([0], dtype=np.bool)
            return (pt2, msk)
        idx = np.empty([0], dtype=np.int32)
        return (pt2, idx)
    (h, w) = np.shape(img2)[:2]
    if ((np.ndim(img1) == 2) or (img1.shape[2] == 1)):
        img1_gray = img1
        img2_gray = img2
    else:
        if (self.tmp_['img1g'] is not None):
            cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY, self.tmp_['img1g'])
            img1_gray = self.tmp_['img1g']
        else:
            img1_gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
            self.tmp_['img1g'] = np.empty_like(img1_gray)
        if (self.tmp_['img2g'] is not None):
            cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY, self.tmp_['img2g'])
            img2_gray = self.tmp_['img2g']
        else:
            img2_gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
            self.tmp_['img2g'] = np.empty_like(img2_gray)
    if (pt2 is not None):
        self.lk_.setFlags((self.lk_.getFlags() | cv2.OPTFLOW_USE_INITIAL_FLOW))
        (pt2, st, _) = self.lk_.calc(img1_gray, img2_gray, pt1, pt2)
    else:
        (pt2, st, _) = self.lk_.calc(img1_gray, img2_gray, pt1, None)
    st_fw = st[:, 0].astype(np.bool)
    self.lk_.setFlags((self.lk_.getFlags() & (~ cv2.OPTFLOW_USE_INITIAL_FLOW)))
    (pt1_r, st, _) = self.lk_.calc(img2_gray, img1_gray, pt2, None)
    st_bw = st[:, 0].astype(np.bool)
    err = np.linalg.norm((pt1 - pt1_r), axis=(- 1))
    msk = np.logical_and.reduce([(err < thresh), (0 <= pt2[:, 0]), (0 <= pt2[:, 1]), (pt2[:, 0] < w), (pt2[:, 1] < h), st_fw, st_bw])
    if return_msk:
        return (pt2, msk)
    else:
        idx = np.where(msk)[0]
        return (pt2, idx)
Arguments:
    img1(np.ndarray) : previous image. (color/mono) (HxWx?)
    img2(np.ndarray) : current image (color/mono) (HxWx?)
    pt1(np.ndarray)  : previous points. (Mx2)
    pt2(np.ndarray)  : [Optional] current points estimate (Mx2)
    thresh(float)    : Flow Back-projection Error threshold

Returns:
    pt2(np.ndarray)  : current points. (Mx2)
    idx(np.ndarray)  : valid tracked indices from pt1 & pt2.
def __call__(self, img1, img2, pt1, pt2=None, thresh=2.0, return_msk=False):
    '\n        Arguments:\n            img1(np.ndarray) : previous image. (color/mono) (HxWx?)\n            img2(np.ndarray) : current image (color/mono) (HxWx?)\n            pt1(np.ndarray)  : previous points. (Mx2)\n            pt2(np.ndarray)  : [Optional] current points estimate (Mx2)\n            thresh(float)    : Flow Back-projection Error threshold\n\n        Returns:\n            pt2(np.ndarray)  : current points. (Mx2)\n            idx(np.ndarray)  : valid tracked indices from pt1 & pt2.\n        '
    if (pt1.size <= 0):
        pt2 = np.empty([0, 2], dtype=np.float32)
        if return_msk:
            msk = np.empty([0], dtype=np.bool)
            return (pt2, msk)
        idx = np.empty([0], dtype=np.int32)
        return (pt2, idx)
    (h, w) = np.shape(img2)[:2]
    if ((np.ndim(img1) == 2) or (img1.shape[2] == 1)):
        img1_gray = img1
        img2_gray = img2
    else:
        if (self.tmp_['img1g'] is not None):
            cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY, self.tmp_['img1g'])
            img1_gray = self.tmp_['img1g']
        else:
            img1_gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
            self.tmp_['img1g'] = np.empty_like(img1_gray)
        if (self.tmp_['img2g'] is not None):
            cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY, self.tmp_['img2g'])
            img2_gray = self.tmp_['img2g']
        else:
            img2_gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
            self.tmp_['img2g'] = np.empty_like(img2_gray)
    if (pt2 is not None):
        self.lk_.setFlags((self.lk_.getFlags() | cv2.OPTFLOW_USE_INITIAL_FLOW))
        (pt2, st, _) = self.lk_.calc(img1_gray, img2_gray, pt1, pt2)
    else:
        (pt2, st, _) = self.lk_.calc(img1_gray, img2_gray, pt1, None)
    st_fw = st[:, 0].astype(np.bool)
    self.lk_.setFlags((self.lk_.getFlags() & (~ cv2.OPTFLOW_USE_INITIAL_FLOW)))
    (pt1_r, st, _) = self.lk_.calc(img2_gray, img1_gray, pt2, None)
    st_bw = st[:, 0].astype(np.bool)
    err = np.linalg.norm((pt1 - pt1_r), axis=(- 1))
    msk = np.logical_and.reduce([(err < thresh), (0 <= pt2[:, 0]), (0 <= pt2[:, 1]), (pt2[:, 0] < w), (pt2[:, 1] < h), st_fw, st_bw])
    if return_msk:
        return (pt2, msk)
    else:
        idx = np.where(msk)[0]
        return (pt2, idx)