add Detection struct to interface

pull/137/head
marina.kolpakova 12 years ago
parent 754fd7311b
commit 8e092f8b5d
  1. 12
      modules/objdetect/include/opencv2/objdetect/objdetect.hpp
  2. 4
      modules/objdetect/perf/perf_cascadeclassifier.cpp
  3. 4
      modules/objdetect/src/softcascade.cpp
  4. 3
      modules/objdetect/test/test_softcascade.cpp

@ -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<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;
protected:

@ -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<cv::Rect> rois, objectBoxes;
std::vector<cv::Rect> rois;
std::vector<detection_t> objectBoxes;
cascade.detectMultiScale(colored, rois, objectBoxes);
TEST_CYCLE()

@ -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<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;
// only color images are supperted

@ -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<cv::Rect> objectBoxes;
std::vector<detection_t> objectBoxes;
std::vector<cv::Rect> rois;
rois.push_back(cv::Rect(0, 0, 640, 480));
// ASSERT_NO_THROW(

Loading…
Cancel
Save