コード例 #1
0
 def _pre_training(self, init_frame, G):
     height, width = G.shape
     fi = cv2.resize(init_frame, (width, height))
     # pre-process img..
     fi = pre_process(fi)
     Ai = G * np.conjugate(np.fft.fft2(fi))
     Bi = np.fft.fft2(init_frame) * np.conjugate(np.fft.fft2(init_frame))
     for _ in range(self.args.num_pretrain):
         if self.args.rotate:
             fi = pre_process(random_warp(init_frame))
         else:
             fi = pre_process(init_frame)
         Ai = Ai + G * np.conjugate(np.fft.fft2(fi))
         Bi = Bi + np.fft.fft2(fi) * np.conjugate(np.fft.fft2(fi))
     
     return Ai, Bi
コード例 #2
0
ファイル: mosse.py プロジェクト: liuxianyi/goog_opencv
 def _pre_training(self, init_frame, G):
     height, width = G.shape
     fi = cv2.resize(init_frame, (width, height))
     # pre-process img..
     fi = pre_process(fi)
     Ai = G * np.conjugate(np.fft.fft2(fi))
     Bi = np.fft.fft2(init_frame) * np.conjugate(np.fft.fft2(init_frame))
     for _ in range(self.args.num_pretrain):
         if self.args.rotate:
             fi = pre_process(random_warp(init_frame))
         else:
             fi = pre_process(init_frame)
         Ai = Ai + G * np.conjugate(np.fft.fft2(fi))
         Bi = Bi + np.fft.fft2(fi) * np.conjugate(np.fft.fft2(fi))
     
     return Ai, Bi
コード例 #3
0
    def _pre_training(self, init_frame, G):
        # G 的大小就是选中的目标区域的大小
        height, width = G.shape
        fi = cv2.resize(init_frame, (width, height))
        # pre-process img..
        fi = pre_process(fi)

        # np.fft.fft2 表示求 fi 的傅立叶变换
        # np.conjugate 表示求矩阵的共轭
        # 比如 g = np.matrix('[1+2j, 2+3j; 3-2j, 1-4j]')
        # g.conjugate 为 matrix([[1-2j, 2-3j],[3+2j, 1+4j]])
        Ai = G * np.conjugate(np.fft.fft2(fi))
        Bi = np.fft.fft2(init_frame) * np.conjugate(np.fft.fft2(init_frame))

        # 对 fi 进行多次刚性形变,增强检测的鲁棒性,计算出 Ai 和 Bi 的初始值
        for _ in range(self.args.num_pretrain):
            if self.args.rotate:
                fi = pre_process(random_warp(init_frame))
            else:
                fi = pre_process(init_frame)
            Ai = Ai + G * np.conjugate(np.fft.fft2(fi))
            Bi = Bi + np.fft.fft2(fi) * np.conjugate(np.fft.fft2(fi))

        return Ai, Bi