From 8e092f8b5d5e910e2ad7e8708bf4ad86d0e8201a Mon Sep 17 00:00:00 2001 From: "marina.kolpakova" Date: Sat, 6 Oct 2012 21:43:25 +0400 Subject: [PATCH] add Detection struct to interface --- modules/objdetect/include/opencv2/objdetect/objdetect.hpp | 12 +++++++++++- modules/objdetect/perf/perf_cascadeclassifier.cpp | 4 +++- modules/objdetect/src/softcascade.cpp | 4 ++-- modules/objdetect/test/test_softcascade.cpp | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp index fd48b32..3724eaa 100644 --- a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp @@ -493,6 +493,16 @@ protected: class CV_EXPORTS SoftCascade { public: + + struct CV_EXPORTS Detection + { + cv::Rect rect; + float confidence; + int kind; + + enum {PEDESTRIAN = 0}; + }; + //! An empty cascade will be created. SoftCascade(); @@ -511,7 +521,7 @@ public: virtual ~SoftCascade(); //! return vector of bounding boxes. Each box contains one detected object - virtual void detectMultiScale(const Mat& image, const std::vector& rois, std::vector& objects, + virtual void detectMultiScale(const Mat& image, const std::vector& rois, std::vector& objects, int rejectfactor = 1) const; protected: diff --git a/modules/objdetect/perf/perf_cascadeclassifier.cpp b/modules/objdetect/perf/perf_cascadeclassifier.cpp index cb21415..271ede0 100644 --- a/modules/objdetect/perf/perf_cascadeclassifier.cpp +++ b/modules/objdetect/perf/perf_cascadeclassifier.cpp @@ -60,13 +60,15 @@ PERF_TEST_P(detect, SoftCascade, testing::Combine(testing::Values(std::string("cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml")), testing::Values(std::string("cv/cascadeandhog/bahnhof/image_00000000_0.png")))) { + typedef cv::SoftCascade::Detection detection_t; cv::Mat colored = imread(getDataPath(get<1>(GetParam()))); ASSERT_FALSE(colored.empty()); cv::SoftCascade cascade; ASSERT_TRUE(cascade.load(getDataPath(get<0>(GetParam())))); - std::vector rois, objectBoxes; + std::vector rois; + std::vector objectBoxes; cascade.detectMultiScale(colored, rois, objectBoxes); TEST_CYCLE() diff --git a/modules/objdetect/src/softcascade.cpp b/modules/objdetect/src/softcascade.cpp index 7363908..8d1853c 100644 --- a/modules/objdetect/src/softcascade.cpp +++ b/modules/objdetect/src/softcascade.cpp @@ -685,10 +685,10 @@ bool cv::SoftCascade::load( const string& filename, const float minScale, const return true; } -//#define DEBUG_SHOW_RESULT +#define DEBUG_SHOW_RESULT void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector& /*rois*/, - std::vector& objects, const int /*rejectfactor*/) const + std::vector& objects, const int /*rejectfactor*/) const { typedef std::vector::const_iterator RIter_t; // only color images are supperted diff --git a/modules/objdetect/test/test_softcascade.cpp b/modules/objdetect/test/test_softcascade.cpp index 9c316fd..00b45f0 100644 --- a/modules/objdetect/test/test_softcascade.cpp +++ b/modules/objdetect/test/test_softcascade.cpp @@ -51,6 +51,7 @@ TEST(SoftCascade, readCascade) TEST(SoftCascade, detect) { + typedef cv::SoftCascade::Detection detection_t; std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/sc_cvpr_2012_to_opencv.xml"; cv::SoftCascade cascade; ASSERT_TRUE(cascade.load(xml)); @@ -58,7 +59,7 @@ TEST(SoftCascade, detect) cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000000_0.png"); ASSERT_FALSE(colored.empty()); - std::vector objectBoxes; + std::vector objectBoxes; std::vector rois; rois.push_back(cv::Rect(0, 0, 640, 480)); // ASSERT_NO_THROW( -- 2.7.4