From 1b5afb45838e603fa6780762eb8cc59246dc2d81 Mon Sep 17 00:00:00 2001
From: IlyaOvodov <b@ovdv.ru>
Date: Tue, 08 May 2018 11:09:35 +0000
Subject: [PATCH] Output improvements for detector results: When printing detector results, output was done in random order, obfuscating results for interpreting. Now: 1. Text output includes coordinates of rects in (left,right,top,bottom in pixels) along with label and score 2. Text output is sorted by rect lefts to simplify finding appropriate rects on image 3. If several class probs are > thresh for some detection, the most probable is written first and coordinates for others are not repeated 4. Rects are imprinted in image in order by their best class prob, so most probable rects are always on top and not overlayed by less probable ones 5. Most probable label for rect is always written first Also: 6. Message about low GPU memory include required amount
---
src/option_list.c | 88 ++++++++++++++++++++++++++++++++++++++++---
1 files changed, 81 insertions(+), 7 deletions(-)
diff --git a/src/option_list.c b/src/option_list.c
index 1b32ebb..9411be3 100644
--- a/src/option_list.c
+++ b/src/option_list.c
@@ -2,12 +2,72 @@
#include <stdio.h>
#include <string.h>
#include "option_list.h"
+#include "utils.h"
-typedef struct{
- char *key;
- char *val;
- int used;
-} kvp;
+list *read_data_cfg(char *filename)
+{
+ FILE *file = fopen(filename, "r");
+ if(file == 0) file_error(filename);
+ char *line;
+ int nu = 0;
+ list *options = make_list();
+ while((line=fgetl(file)) != 0){
+ ++ nu;
+ strip(line);
+ switch(line[0]){
+ case '\0':
+ case '#':
+ case ';':
+ free(line);
+ break;
+ default:
+ if(!read_option(line, options)){
+ fprintf(stderr, "Config file error line %d, could parse: %s\n", nu, line);
+ free(line);
+ }
+ break;
+ }
+ }
+ fclose(file);
+ return options;
+}
+
+metadata get_metadata(char *file)
+{
+ metadata m = { 0 };
+ list *options = read_data_cfg(file);
+
+ char *name_list = option_find_str(options, "names", 0);
+ if (!name_list) name_list = option_find_str(options, "labels", 0);
+ if (!name_list) {
+ fprintf(stderr, "No names or labels found\n");
+ }
+ else {
+ m.names = get_labels(name_list);
+ }
+ m.classes = option_find_int(options, "classes", 2);
+ free_list(options);
+ printf("Loaded - names_list: %s, classes = %d \n", name_list, m.classes);
+ return m;
+}
+
+int read_option(char *s, list *options)
+{
+ size_t i;
+ size_t len = strlen(s);
+ char *val = 0;
+ for(i = 0; i < len; ++i){
+ if(s[i] == '='){
+ s[i] = '\0';
+ val = s+i+1;
+ break;
+ }
+ }
+ if(i == len-1) return 0;
+ char *key = s;
+ option_insert(options, key, val);
+ return 1;
+}
void option_insert(list *l, char *key, char *val)
{
@@ -47,7 +107,7 @@
{
char *v = option_find(l, key);
if(v) return v;
- fprintf(stderr, "%s: Using default '%s'\n", key, def);
+ if(def) fprintf(stderr, "%s: Using default '%s'\n", key, def);
return def;
}
@@ -59,7 +119,21 @@
return def;
}
-double option_find_double(list *l, char *key, double def)
+int option_find_int_quiet(list *l, char *key, int def)
+{
+ char *v = option_find(l, key);
+ if(v) return atoi(v);
+ return def;
+}
+
+float option_find_float_quiet(list *l, char *key, float def)
+{
+ char *v = option_find(l, key);
+ if(v) return atof(v);
+ return def;
+}
+
+float option_find_float(list *l, char *key, float def)
{
char *v = option_find(l, key);
if(v) return atof(v);
--
Gitblit v1.10.0