From 57fa745be879e9fcbe007651bd190d3a40de3f38 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Fri, 04 Aug 2017 20:31:12 +0000
Subject: [PATCH] Fixed speed of SO/DLL

---
 src/yolo_v2_class.cpp |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/src/yolo_v2_class.cpp b/src/yolo_v2_class.cpp
index 31f623c..813a24f 100644
--- a/src/yolo_v2_class.cpp
+++ b/src/yolo_v2_class.cpp
@@ -102,6 +102,15 @@
 #endif
 }
 
+YOLODLL_API int Detector::get_net_width() {
+	detector_gpu_t &detector_gpu = *reinterpret_cast<detector_gpu_t *>(detector_gpu_ptr.get());
+	return detector_gpu.net.w;
+}
+YOLODLL_API int Detector::get_net_height() {
+	detector_gpu_t &detector_gpu = *reinterpret_cast<detector_gpu_t *>(detector_gpu_ptr.get());
+	return detector_gpu.net.h;
+}
+
 
 YOLODLL_API std::vector<bbox_t> Detector::detect(std::string image_filename, float thresh)
 {
@@ -174,7 +183,15 @@
 	im.h = img.h;
 	im.w = img.w;
 
-	image sized = resize_image(im, net.w, net.h);
+	image sized;
+	
+	if (net.w == im.w && net.h == im.h) {
+		sized = make_image(im.w, im.h, im.c);
+		memcpy(sized.data, im.data, im.w*im.h*im.c * sizeof(float));
+	}
+	else
+		sized = resize_image(im, net.w, net.h);
+
 	layer l = net.layers[net.n - 1];
 
 	float *X = sized.data;

--
Gitblit v1.10.0