Exemple #1
0
        private static int nms_comparator(SortableBbox a, SortableBbox b)
        {
            float diff = a.Probs[a.Index][b.Sclass] - b.Probs[b.Index][b.Sclass];

            if (diff < 0)
            {
                return(1);
            }
            if (diff > 0)
            {
                return(-1);
            }
            return(0);
        }
Exemple #2
0
        public static void do_nms_sort(Box[] boxes, float[][] probs, int total, int classes, float thresh)
        {
            int i, j, k;

            SortableBbox[] s = new SortableBbox[total];

            for (i = 0; i < total; ++i)
            {
                s[i].Index  = i;
                s[i].Sclass = 0;
                s[i].Probs  = probs;
            }

            for (k = 0; k < classes; ++k)
            {
                for (i = 0; i < total; ++i)
                {
                    s[i].Sclass = k;
                }
                Array.Sort(s, nms_comparator);
                for (i = 0; i < total; ++i)
                {
                    if (probs[s[i].Index][k] == 0)
                    {
                        continue;
                    }
                    Box a = boxes[s[i].Index];
                    for (j = i + 1; j < total; ++j)
                    {
                        Box b = boxes[s[j].Index];
                        if (box_iou(a, b) > thresh)
                        {
                            probs[s[j].Index][k] = 0;
                        }
                    }
                }
            }
        }