Esempio n. 1
0
    def predict(self, bbox, time, fid):
        bbox = bbox[:4]

        if fid == 0:
            self.pre_bbox = np.array(bbox)

        bbox = Exponentially_weighted_averages(self.pre_bbox,
                                               bbox,
                                               fid,
                                               theta=0.8)

        x, y = bird_view_proj((bbox[0] + bbox[2]) / 2, bbox[3], self.K,
                              self.dist_coeff, self.R, self.T)
        x = np.sqrt(x * x - 3.8**2)

        interval = 5
        if fid == 0:
            self.pre_vx = 0.
            self.pre_bbox = np.array(bbox)
            time_diff = 0x3ffffff
        elif fid >= interval:
            time_diff = time - self.times[-interval]
            self.pre_x = self.result[-interval]['x']
        else:
            time_diff = time - self.times[0]
            self.pre_x = self.result[0]['x']

        self.times.append(time)
        vx = (x - self.pre_x) / time_diff

        if len(self.result) == 1:
            self.pre_vx = vx

        vx = Exponentially_weighted_averages(self.pre_vx, vx, fid, theta=0.9)

        self.pre_bbox = bbox
        self.pre_x = x
        self.pre_vx = vx

        cur_pred = {
            'fid': fid,
            'vx': vx,
            'x': x,
            #             'ref_bbox': {
            #                 'left': float(bbox[0]), 'top': float(bbox[1]),
            #                 'right': float(bbox[2]), 'bot': float(bbox[3])
            #             }
        }

        self.result.append(cur_pred)

        return cur_pred
Esempio n. 2
0
 def proj(self, u, v):
     x, y = bird_view_proj(u, v, self.K, self.dist_coeff, self.R, self.T)
     return x, y