From 81751b47dd5d2e63f571f048bdd0a6a2a45617b0 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Mon, 30 Mar 2015 19:04:03 +0000
Subject: [PATCH] ..... and back to coords
---
src/detection.c | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/detection.c b/src/detection.c
index 69202aa..bdced37 100644
--- a/src/detection.c
+++ b/src/detection.c
@@ -27,12 +27,11 @@
float blue = get_color(2,class,classes);
j += classes;
- int d = im.w/side;
- int y = r*d+box[j]*d;
- int x = c*d+box[j+1]*d;
- int h = box[j+2]*im.h;
- int w = box[j+3]*im.w;
- draw_box(im, x-w/2, y-h/2, x+w/2, y+h/2,red,green,blue);
+ int left = box[j] *im.w;
+ int right = box[j+1]*im.w;
+ int top = box[j+2]*im.h;
+ int bot = box[j+3]*im.h;
+ draw_box(im, left, top, right, bot, red, green, blue);
}
}
}
@@ -112,7 +111,9 @@
int classes = 20;
int background = 0;
int nuisance = 1;
- int num_output = 7*7*(4+classes+background+nuisance);
+ int num_boxes = 7;
+ int per_box = 4+classes+background+nuisance;
+ int num_output = num_boxes*num_boxes*per_box;
int m = plist->size;
int i = 0;
@@ -136,16 +137,16 @@
matrix pred = network_predict_data(net, val);
int j, k, class;
for(j = 0; j < pred.rows; ++j){
- for(k = 0; k < pred.cols; k += classes+4+background+nuisance){
+ for(k = 0; k < pred.cols; k += per_box){
float scale = 1.;
- if(nuisance) scale = 1.-pred.vals[j][k];
- for(class = 0; class < classes; ++class){
- int index = (k)/(classes+4+background+nuisance);
- int r = index/7;
- int c = index%7;
+ int index = k/per_box;
+ int row = index / num_boxes;
+ int col = index % num_boxes;
+ if (nuisance) scale = 1.-pred.vals[j][k];
+ for (class = 0; class < classes; ++class){
int ci = k+classes+background+nuisance;
- float y = (r + pred.vals[j][ci + 0])/7.;
- float x = (c + pred.vals[j][ci + 1])/7.;
+ float y = (pred.vals[j][ci + 0] + row)/num_boxes;
+ float x = (pred.vals[j][ci + 1] + col)/num_boxes;
float h = pred.vals[j][ci + 2];
float w = pred.vals[j][ci + 3];
printf("%d %d %f %f %f %f %f\n", (i-1)*m/splits + j, class, scale*pred.vals[j][k+class+background+nuisance], y, x, h, w);
--
Gitblit v1.10.0