From fd671a7a4a8f018e449966a8ada5020de702d742 Mon Sep 17 00:00:00 2001
From: AlexeyAB <kikots@mail.ru>
Date: Fri, 04 Aug 2017 14:57:05 +0000
Subject: [PATCH] LIBSO=1 compile darknet.so library on Linux

---
 src/yolo_v2_class.hpp |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/yolo_v2_class.hpp b/src/yolo_v2_class.hpp
index 34e220a..9a8baa6 100644
--- a/src/yolo_v2_class.hpp
+++ b/src/yolo_v2_class.hpp
@@ -11,9 +11,17 @@
 #endif	// OPENCV
 
 #ifdef YOLODLL_EXPORTS
+#if defined(_MSC_VER)
 #define YOLODLL_API __declspec(dllexport) 
 #else
+#define YOLODLL_API __attribute__((visibility("default")))
+#endif
+#else
+#if defined(_MSC_VER)
 #define YOLODLL_API __declspec(dllimport) 
+#else
+#define YOLODLL_API
+#endif
 #endif
 
 struct bbox_t {
@@ -51,20 +59,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