Commit 8e092f8b authored by marina.kolpakova's avatar marina.kolpakova

add Detection struct to interface

parent 754fd731
...@@ -493,6 +493,16 @@ protected: ...@@ -493,6 +493,16 @@ protected:
class CV_EXPORTS SoftCascade class CV_EXPORTS SoftCascade
{ {
public: public:
struct CV_EXPORTS Detection
{
cv::Rect rect;
float confidence;
int kind;
enum {PEDESTRIAN = 0};
};
//! An empty cascade will be created. //! An empty cascade will be created.
SoftCascade(); SoftCascade();
...@@ -511,7 +521,7 @@ public: ...@@ -511,7 +521,7 @@ public:
virtual ~SoftCascade(); virtual ~SoftCascade();
//! return vector of bounding boxes. Each box contains one detected object //! return vector of bounding boxes. Each box contains one detected object
virtual void detectMultiScale(const Mat& image, const std::vector<cv::Rect>& rois, std::vector<cv::Rect>& objects, virtual void detectMultiScale(const Mat& image, const std::vector<cv::Rect>& rois, std::vector<Detection>& objects,
int rejectfactor = 1) const; int rejectfactor = 1) const;
protected: protected:
......
...@@ -60,13 +60,15 @@ PERF_TEST_P(detect, SoftCascade, ...@@ -60,13 +60,15 @@ PERF_TEST_P(detect, SoftCascade,
testing::Combine(testing::Values(std::string("cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml")), 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")))) 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()))); cv::Mat colored = imread(getDataPath(get<1>(GetParam())));
ASSERT_FALSE(colored.empty()); ASSERT_FALSE(colored.empty());
cv::SoftCascade cascade; cv::SoftCascade cascade;
ASSERT_TRUE(cascade.load(getDataPath(get<0>(GetParam())))); ASSERT_TRUE(cascade.load(getDataPath(get<0>(GetParam()))));
std::vector<cv::Rect> rois, objectBoxes; std::vector<cv::Rect> rois;
std::vector<detection_t> objectBoxes;
cascade.detectMultiScale(colored, rois, objectBoxes); cascade.detectMultiScale(colored, rois, objectBoxes);
TEST_CYCLE() TEST_CYCLE()
......
...@@ -685,10 +685,10 @@ bool cv::SoftCascade::load( const string& filename, const float minScale, const ...@@ -685,10 +685,10 @@ bool cv::SoftCascade::load( const string& filename, const float minScale, const
return true; return true;
} }
//#define DEBUG_SHOW_RESULT #define DEBUG_SHOW_RESULT
void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector<cv::Rect>& /*rois*/, void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector<cv::Rect>& /*rois*/,
std::vector<cv::Rect>& objects, const int /*rejectfactor*/) const std::vector<Detection>& objects, const int /*rejectfactor*/) const
{ {
typedef std::vector<cv::Rect>::const_iterator RIter_t; typedef std::vector<cv::Rect>::const_iterator RIter_t;
// only color images are supperted // only color images are supperted
......
...@@ -51,6 +51,7 @@ TEST(SoftCascade, readCascade) ...@@ -51,6 +51,7 @@ TEST(SoftCascade, readCascade)
TEST(SoftCascade, detect) 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"; std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/sc_cvpr_2012_to_opencv.xml";
cv::SoftCascade cascade; cv::SoftCascade cascade;
ASSERT_TRUE(cascade.load(xml)); ASSERT_TRUE(cascade.load(xml));
...@@ -58,7 +59,7 @@ TEST(SoftCascade, detect) ...@@ -58,7 +59,7 @@ TEST(SoftCascade, detect)
cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000000_0.png"); cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000000_0.png");
ASSERT_FALSE(colored.empty()); ASSERT_FALSE(colored.empty());
std::vector<cv::Rect> objectBoxes; std::vector<detection_t> objectBoxes;
std::vector<cv::Rect> rois; std::vector<cv::Rect> rois;
rois.push_back(cv::Rect(0, 0, 640, 480)); rois.push_back(cv::Rect(0, 0, 640, 480));
// ASSERT_NO_THROW( // ASSERT_NO_THROW(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment