From 805f4b6c0c0861b718af0b925a70b1f4f9b8038a Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Wed, 18 Feb 2015 10:47:10 -0500 Subject: [PATCH] Detector is not thread safe --- openbr/plugins/dlib.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openbr/plugins/dlib.cpp b/openbr/plugins/dlib.cpp index 564cb24..f79d852 100644 --- a/openbr/plugins/dlib.cpp +++ b/openbr/plugins/dlib.cpp @@ -80,6 +80,7 @@ class DObjectDetectTransform : public Transform private: typedef scan_fhog_pyramid > image_scanner_type; mutable object_detector detector; + mutable QMutex mutex; void train(const TemplateList &data) { @@ -88,7 +89,7 @@ private: foreach (const Template &t, data) { if (!t.file.rects().isEmpty()) { - cv_image cimg(t.m().clone()); + cv_image cimg(t.m().clone()); array2d image; assign_image(image,cimg); @@ -115,18 +116,21 @@ private: trainer.set_num_threads(max(1,QThread::idealThreadCount())); trainer.set_c(C); trainer.set_epsilon(epsilon); + trainer.be_verbose(); detector = trainer.train(samples, boxes); } void project(const Template &src, Template &dst) const - { + { dst = src; - cv_image cimg(src.m().clone()); + cv_image cimg(src.m().clone()); array2d image; assign_image(image,cimg); + QMutexLocker locker(&mutex); std::vector dets = detector(image); + locker.unlock(); for (int i=0; i