From f88d23ad34fc0a33c32caa98830a56c53f1cd844 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Tue, 26 Jun 2018 22:54:09 +0000
Subject: [PATCH] Minor fix

---
 src/yolo_v2_class.cpp |   27 +++++++++++----------------
 src/detector.c        |    7 ++++---
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/detector.c b/src/detector.c
index afb91b2..15729e2 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -61,12 +61,13 @@
     srand(time(0));
     network net = nets[0];
 
-	if ((net.batch * net.subdivisions) == 1) {
+	const int actual_batch_size = net.batch * net.subdivisions;
+	if (actual_batch_size == 1) {
 		printf("\n Error: You set incorrect value batch=1 for Training! You should set batch=64 subdivision=64 \n");
 		getchar();
 	}
-	else if ((net.batch * net.subdivisions) < 64) {
-			printf("\n Warning: You set batch= lower than 64! It is recommended to set batch=64 subdivision=64 \n");
+	else if (actual_batch_size < 64) {
+			printf("\n Warning: You set batch=%d lower than 64! It is recommended to set batch=64 subdivision=64 \n", actual_batch_size);
 	}
 
     int imgs = net.batch * net.subdivisions * ngpus;
diff --git a/src/yolo_v2_class.cpp b/src/yolo_v2_class.cpp
index adba732..c518fd7 100644
--- a/src/yolo_v2_class.cpp
+++ b/src/yolo_v2_class.cpp
@@ -24,24 +24,18 @@
 
 int max_objects() { return C_SHARP_MAX_OBJECTS; }
 
-static Detector* detector;
-//static std::unique_ptr<Detector> detector;
+//static Detector* detector = NULL;
+static std::unique_ptr<Detector> detector;
 
-int init(const char *configurationFilename, const char *weightsFilename, int gpu) {
-    std::string configurationFilenameString;
-    configurationFilenameString = configurationFilename;
-    std::string weightsFilenameString;
-    weightsFilenameString = weightsFilename;
-
-    detector = new Detector(configurationFilenameString, weightsFilenameString, gpu);
+int init(const char *configurationFilename, const char *weightsFilename, int gpu) 
+{
+    detector.reset(new Detector(configurationFilename, weightsFilename, gpu));
     return 1;
 }
 
-int detect_image(const char *filename, bbox_t_container &container) {
-    std::string filenameString;
-    filenameString = filename;
-
-    std::vector<bbox_t> detection = detector->detect(filenameString);
+int detect_image(const char *filename, bbox_t_container &container) 
+{
+    std::vector<bbox_t> detection = detector->detect(filename);
     for (size_t i = 0; i < detection.size() && i < C_SHARP_MAX_OBJECTS; ++i)
         container.candidates[i] = detection[i];
     return detection.size();
@@ -62,8 +56,9 @@
 }
 
 int dispose() {
-    detector->~Detector();
-    //detector.reset();
+	//if (detector != NULL) delete detector;
+	//detector = NULL;
+    detector.reset();
     return 1;
 }
 

--
Gitblit v1.10.0