From 84d6533cb8112f23a34d3de76435a10f4620f4b8 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Mon, 23 Oct 2017 13:43:03 +0000
Subject: [PATCH] Fixed OpenCV usage in the yolo_console_dll.cpp
---
src/utils.c | 42 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/src/utils.c b/src/utils.c
index 41e71d0..f340a7e 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -3,10 +3,13 @@
#include <string.h>
#include <math.h>
#include <assert.h>
-#include "unistd.h"
#include <float.h>
#include <limits.h>
-
+#ifdef WIN32
+#include "unistd.h"
+#else
+#include <unistd.h>
+#endif
#include "utils.h"
#pragma warning(disable: 4996)
@@ -123,6 +126,7 @@
{
c = next+1;
}
+ if(!next) while ((next = strchr(c, '\\'))) { c = next + 1; }
c = copy_string(c);
next = strchr(c, '.');
if (next) *next = 0;
@@ -604,12 +608,13 @@
max = swap;
}
return ((float)rand()/RAND_MAX * (max - min)) + min;
+ //return (random_float() * (max - min)) + min;
}
float rand_scale(float s)
{
- float scale = rand_uniform(1, s);
- if(rand()%2) return scale;
+ float scale = rand_uniform_strong(1, s);
+ if(random_gen()%2) return scale;
return 1./scale;
}
@@ -625,3 +630,32 @@
return t;
}
+unsigned int random_gen()
+{
+ unsigned int rnd = 0;
+#ifdef WIN32
+ rand_s(&rnd);
+#else
+ rnd = rand();
+#endif
+ return rnd;
+}
+
+float random_float()
+{
+#ifdef WIN32
+ return ((float)random_gen() / (float)UINT_MAX);
+#else
+ return ((float)random_gen() / (float)RAND_MAX);
+#endif
+}
+
+float rand_uniform_strong(float min, float max)
+{
+ if (max < min) {
+ float swap = min;
+ min = max;
+ max = swap;
+ }
+ return (random_float() * (max - min)) + min;
+}
\ No newline at end of file
--
Gitblit v1.10.0