From 37921caad3c9a09bcdaba56453e35ab12dabb30f Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Mon, 24 Jul 2017 18:43:44 +0000
Subject: [PATCH] Fix that allows speedup usage of Yolo-DLL

---
 src/yolo_console_dll.cpp |    1 +
 src/yolo_v2_class.hpp    |   14 +++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/yolo_console_dll.cpp b/src/yolo_console_dll.cpp
index 5172b5e..b378b7f 100644
--- a/src/yolo_console_dll.cpp
+++ b/src/yolo_console_dll.cpp
@@ -3,6 +3,7 @@
 #include <string>
 #include <vector>
 #include <fstream>
+#include <thread>
 
 #define OPENCV
 
diff --git a/src/yolo_v2_class.hpp b/src/yolo_v2_class.hpp
index 34e220a..8330dfc 100644
--- a/src/yolo_v2_class.hpp
+++ b/src/yolo_v2_class.hpp
@@ -51,20 +51,20 @@
 	{
 		if(mat.data == NULL)
 			throw std::runtime_error("file not found");
-		std::shared_ptr<image_t> image_ptr(new image_t, [](image_t *img) { free_image(*img); delete img; });
-		*image_ptr = mat_to_image(mat);
+		auto image_ptr = mat_to_image(mat);
 		return detect(*image_ptr, thresh);
 	}
 
-private:
-	static image_t mat_to_image(cv::Mat img)
+	static std::shared_ptr<image_t> mat_to_image(cv::Mat img)
 	{
+		std::shared_ptr<image_t> image_ptr(new image_t, [](image_t *img) { free_image(*img); delete img; });
 		std::shared_ptr<IplImage> ipl_small = std::make_shared<IplImage>(img);
-		image_t im_small = ipl_to_image(ipl_small.get());
-		rgbgr_image(im_small);
-		return im_small;
+		*image_ptr = ipl_to_image(ipl_small.get());
+		rgbgr_image(*image_ptr);
+		return image_ptr;
 	}
 
+private:
 	static image_t ipl_to_image(IplImage* src)
 	{
 		unsigned char *data = (unsigned char *)src->imageData;

--
Gitblit v1.10.0