예제 #1
0
 def trans(self, boxes):
     """
     # Args
         boxes : array, shape of (N, 4)
             (x1, y1, x2, y2)-ordered & input image size scale coordinate
     
     # Returns
         norm_boxes : array, same shape of boxes
             (cx, cy, w, h)-ordered & rescaled to grid-size
     """
     # 1. minimax box -> centroid box
     centroid_boxes = to_centroid(boxes).astype(np.float32)
     # 2. image scale -> grid scale
     norm_boxes = centroid_boxes * (self._grid_size / self._input_size)
     return norm_boxes
예제 #2
0
 def trans(self, boxes):
     """
     # Args
         boxes : array, shape of (N, 4)
             (x1, y1, x2, y2)-ordered & input image size scale coordinate
     
     # Returns
         norm_boxes : array, same shape of boxes
             (cx, cy, w, h)-ordered & rescaled to grid-size
     """
     # 1. [[100, 120, 140, 200]] minimax box -> centroid box
     centroid_boxes = to_centroid(boxes).astype(np.float32)
     # 2. [[120. 160.  40.  80.]] image scale -> grid scale [[4.        5.        1.3333334 2.5      ]]
     norm_boxes = np.zeros_like(centroid_boxes)
     norm_boxes[:,0::2] = centroid_boxes[:,0::2] * (self._grid_size[0] / self._input_size[0])
     norm_boxes[:,1::2] = centroid_boxes[:,1::2] * (self._grid_size[1] / self._input_size[1])
     #print(norm_boxes)
     return norm_boxes