From a9e16d914a5e1247c4149d95afbe8f68ca846a53 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Wed, 23 Sep 2015 00:34:48 +0000
Subject: [PATCH] more writing stuff

---
 src/box.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/box.c b/src/box.c
index d49be41..b99300d 100644
--- a/src/box.c
+++ b/src/box.c
@@ -2,6 +2,16 @@
 #include <stdio.h>
 #include <math.h>
 
+box float_to_box(float *f)
+{
+    box b;
+    b.x = f[0];
+    b.y = f[1];
+    b.w = f[2];
+    b.h = f[3];
+    return b;
+}
+
 dbox derivative(box a, box b)
 {
     dbox d;
@@ -85,6 +95,14 @@
     return box_intersection(a, b)/box_union(a, b);
 }
 
+float box_rmse(box a, box b)
+{
+    return sqrt(pow(a.x-b.x, 2) + 
+                pow(a.y-b.y, 2) + 
+                pow(a.w-b.w, 2) + 
+                pow(a.h-b.h, 2));
+}
+
 dbox dintersect(box a, box b)
 {
     float w = overlap(a.x, a.w, b.x, b.w);
@@ -211,16 +229,16 @@
     return dd;
 }
 
-void do_nms(box *boxes, float **probs, int num_boxes, int classes, float thresh)
+void do_nms(box *boxes, float **probs, int total, int classes, float thresh)
 {
     int i, j, k;
-    for(i = 0; i < num_boxes*num_boxes; ++i){
+    for(i = 0; i < total; ++i){
         int any = 0;
         for(k = 0; k < classes; ++k) any = any || (probs[i][k] > 0);
         if(!any) {
             continue;
         }
-        for(j = i+1; j < num_boxes*num_boxes; ++j){
+        for(j = i+1; j < total; ++j){
             if (box_iou(boxes[i], boxes[j]) > thresh){
                 for(k = 0; k < classes; ++k){
                     if (probs[i][k] < probs[j][k]) probs[i][k] = 0;

--
Gitblit v1.10.0