Exemplo n.º 1
0
 def apply_bbox(self, bbox, s):
     for op_name in s:
         A = aug.AUG_AS[op_name](**s[op_name])
         bbox[:2] = aug.apply_A(bbox[:2], A)
         bbox[2:4] = aug.apply_A(bbox[2:4], A)
     out_h, out_w = (np.array(self.size) // self.stride).astype(int)
     bbox[[0, 2]] = np.clip(bbox[[0, 2]], 0, out_w - 1)
     bbox[[1, 3]] = np.clip(bbox[[1, 3]], 0, out_h - 1)
     return bbox
Exemplo n.º 2
0
 def apply_bbox(self, bbox, s):
     for op_name in s:
         A = aug.AUG_AS[op_name](**s[op_name])
         tlx, tly, brx, bry = bbox
         trx, tr_y, blx, bly = brx, tly, tlx, bry
         tlx, tly = aug.apply_A([tlx, tly], A)
         brx, bry = aug.apply_A([brx, bry], A)
         trx, tr_y = aug.apply_A([trx, tr_y], A)
         blx, bly = aug.apply_A([blx, bly], A)
         x1 = np.array([tlx, trx, blx, brx]).min()
         y1 = np.array([tly, tr_y, bly, bry]).min()
         x2 = np.array([tlx, trx, blx, brx]).max()
         y2 = np.array([tly, tr_y, bly, bry]).max()
         bbox = np.array([x1, y1, x2, y2])
     out_w, out_h = np.array(self.size)
     bbox[[0, 2]] = np.clip(bbox[[0, 2]], 0, out_w - 1)
     bbox[[1, 3]] = np.clip(bbox[[1, 3]], 0, out_h - 1)
     return bbox
Exemplo n.º 3
0
 def apply_pts(self, cid, pts, s):
     for op_name in s:
         A = aug.AUG_AS[op_name](**s[op_name])
         for i in range(pts.shape[0]):
             pts[i, :2] = aug.apply_A(pts[i, :2], A)
             if ((pts[i, :2] < 0).sum() + (pts[i, :2] >
                                           (out_w, out_h)).sum()) > 0:
                 pts[i, 2] = 0.0
     return pts
Exemplo n.º 4
0
 def apply_pts(self, cid, pts, s):
     out_h, out_w = (np.array(self.size) // self.stride).astype(int)
     for op_name in s:
         A = aug.AUG_AS[op_name](**s[op_name])
         for i in range(pts.shape[0]):
             pts[i, :2] = aug.apply_A(pts[i, :2], A)
             if ((pts[i, :2] < 0).sum() + (pts[i, :2] >
                                           (out_w, out_h)).sum()) > 0:
                 pts[i, 2] = 0.0
     return pts
 def apply_pts(self, cid, pts, s):
     for op_name in s:
         A = aug.AUG_AS[op_name](**s[op_name])
         for i in range(pts.shape[0]):
             pts[i] = aug.apply_A(pts[i], A)
     return pts
 def apply_bbox(self, bbox, s):
     for op_name in s:
         A = aug.AUG_AS[op_name](**s[op_name])
         bbox[:2] = aug.apply_A(bbox[:2], A)
         bbox[2:] = aug.apply_A(bbox[2:], A)
     return bbox