'Update internal records. This function now only update internal buffer,
sum_metric and num_inst are updated in _update() function instead when
get() is called to return results.
Params:
labels: mx.nd.array (n * 6) or (n * 5), difficult column is optional
2-d array of ground-truths, n objects(id-xmin-ymin-xmax-ymax-[difficult])
preds: mx.nd.array (m * 6)
2-d array of detections, m objects(id-score-xmin-ymin-xmax-ymax)'

def update(self, labels, preds):

    def iou(x, ys):
        '\n                                                Calculate    intersection-over-union    overlap\n                                                Params:\n                                                ----------\n                                                x    :    numpy.array\n                                                                single    box    [xmin,    ymin    ,xmax,    ymax]\n                                                ys    :    numpy.array\n                                                                multiple    box    [[xmin,    ymin,    xmax,    ymax],    [...],    ]\n                                                Returns:\n                                                -----------\n                                                numpy.array\n                                                                [iou1,    iou2,    ...],    size    ==    ys.shape[0]\n                                                '
        ixmin = np.maximum(ys[:, 0], x[0])
        iymin = np.maximum(ys[:, 1], x[1])
        ixmax = np.minimum(ys[:, 2], x[2])
        iymax = np.minimum(ys[:, 3], x[3])
        iw = np.maximum((ixmax - ixmin), 0.0)
        ih = np.maximum((iymax - iymin), 0.0)
        inters = (iw * ih)
        uni = ((((x[2] - x[0]) * (x[3] - x[1])) + ((ys[:, 2] - ys[:, 0]) * (ys[:, 3] - ys[:, 1]))) - inters)
        ious = (inters / uni)
        ious[(uni < 1e-12)] = 0
        return ious
    for i in range(labels[0].shape[0]):
        label = labels[0][i].asnumpy()
        if (np.sum((label[:, 0] >= 0)) < 1):
            continue
        pred = preds[self.pred_idx][i].asnumpy()
        while (pred.shape[0] > 0):
            cid = int(pred[(0, 0)])
            indices = np.where((pred[:, 0].astype(int) == cid))[0]
            if (cid < 0):
                pred = np.delete(pred, indices, axis=0)
                continue
            dets = pred[indices]
            pred = np.delete(pred, indices, axis=0)
            dets[dets[:, 1].argsort()[::(-1)]]
            records = np.hstack((dets[:, 1][:, np.newaxis], np.zeros((dets.shape[0], 1))))
            label_indices = np.where((label[:, 0].astype(int) == cid))[0]
            gts = label[label_indices, :]
            label = np.delete(label, label_indices, axis=0)
            if (gts.size > 0):
                found = ([False] * gts.shape[0])
                for j in range(dets.shape[0]):
                    ious = iou(dets[j, 2:], gts[:, 1:5])
                    ovargmax = np.argmax(ious)
                    ovmax = ious[ovargmax]
                    if (ovmax > self.ovp_thresh):
                        if ((not self.use_difficult) and (gts.shape[1] >= 6) and (gts[(ovargmax, 5)] > 0)):
                            pass
                        elif (not found[ovargmax]):
                            records[(j, (-1))] = 1
                            found[ovargmax] = True
                        else:
                            records[(j, (-1))] = 2
                    else:
                        records[(j, (-1))] = 2
            else:
                records[:, (-1)] = 2
            if ((not self.use_difficult) and (gts.shape[1] >= 6)):
                gt_count = np.sum((gts[:, 5] < 1))
            else:
                gt_count = gts.shape[0]
            records = records[np.where((records[:, (-1)] > 0))[0], :]
            if (records.size > 0):
                self._insert(cid, records, gt_count)
        while (label.shape[0] > 0):
            cid = int(label[(0, 0)])
            label_indices = np.where((label[:, 0].astype(int) == cid))[0]
            label = np.delete(label, label_indices, axis=0)
            if (cid < 0):
                continue
            gt_count = label_indices.size
            self._insert(cid, np.array([[0, 0]]), gt_count)
