From 04c0c4fdf84bb7b9e89604e8b9a6079016d5968c Mon Sep 17 00:00:00 2001
From: Alexey <AlexeyAB@users.noreply.github.com>
Date: Wed, 04 Jul 2018 16:06:41 +0000
Subject: [PATCH] Merge pull request #1132 from tinohager/master
---
src/yolo_v2_class.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/src/yolo_v2_class.cpp b/src/yolo_v2_class.cpp
index 6cc0252..4df9be5 100644
--- a/src/yolo_v2_class.cpp
+++ b/src/yolo_v2_class.cpp
@@ -22,6 +22,44 @@
#define FRAMES 3
+//static Detector* detector = NULL;
+static std::unique_ptr<Detector> detector;
+
+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::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();
+}
+
+int detect_mat(const uint8_t* data, const size_t data_length, bbox_t_container &container) {
+#ifdef OPENCV
+ std::vector<char> vdata(data, data + data_length);
+ cv::Mat image = imdecode(cv::Mat(vdata), 1);
+
+ std::vector<bbox_t> detection = detector->detect(image);
+ for (size_t i = 0; i < detection.size() && i < C_SHARP_MAX_OBJECTS; ++i)
+ container.candidates[i] = detection[i];
+ return detection.size();
+#else
+ return -1;
+#endif // OPENCV
+}
+
+int dispose() {
+ //if (detector != NULL) delete detector;
+ //detector = NULL;
+ detector.reset();
+ return 1;
+}
+
#ifdef GPU
void check_cuda(cudaError_t status) {
if (status != cudaSuccess) {
@@ -119,6 +157,10 @@
detector_gpu_t &detector_gpu = *static_cast<detector_gpu_t *>(detector_gpu_ptr.get());
return detector_gpu.net.h;
}
+YOLODLL_API int Detector::get_net_color_depth() const {
+ detector_gpu_t &detector_gpu = *static_cast<detector_gpu_t *>(detector_gpu_ptr.get());
+ return detector_gpu.net.c;
+}
YOLODLL_API std::vector<bbox_t> Detector::detect(std::string image_filename, float thresh, bool use_mean)
@@ -222,7 +264,7 @@
int letterbox = 0;
float hier_thresh = 0.5;
detection *dets = get_network_boxes(&net, im.w, im.h, thresh, hier_thresh, 0, 1, &nboxes, letterbox);
- if (nms) do_nms_sort_v3(dets, nboxes, l.classes, nms);
+ if (nms) do_nms_sort(dets, nboxes, l.classes, nms);
std::vector<bbox_t> bbox_vec;
--
Gitblit v1.10.0