class CV_EXPORTS SoftCascade
{
public:
+ //! empty cascade will be created.
SoftCascade();
+
+ //! cascade will be loaded from file "filename"
SoftCascade( const string& filename, const float minScale = 0.4f, const float maxScale = 5.f);
- virtual ~SoftCascade();
bool load( const string& filename, const float minScale = 0.4f, const float maxScale = 5.f);
- virtual void detectMultiScale(const Mat& image, const std::vector<cv::Rect>& rois, std::vector<cv::Rect>& objects, double factor = 1.05, int step = 4, int rejectfactor = 1);
+ virtual ~SoftCascade();
+
+ //! return vector of bounding boxes. Each box contains detected object
+ virtual void detectMultiScale(const Mat& image, const std::vector<cv::Rect>& rois, std::vector<cv::Rect>& objects,
+ int step = 4, int rejectfactor = 1);
protected:
virtual void detectForOctave(int octave);
filds = new Filds;
Filds& flds = *filds;
if (!flds.fill(fs.getFirstTopLevelNode(), minScale, maxScale)) return false;
- // flds.calcLevels(FRAME_WIDTH, FRAME_HEIGHT, TOTAL_SCALES);
+ flds.calcLevels(FRAME_WIDTH, FRAME_HEIGHT, TOTAL_SCALES);
return true;
}
void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector<cv::Rect>& rois, std::vector<cv::Rect>& objects,
- const double factor, const int step, const int rejectfactor)
-{}
+ const int step, const int rejectfactor)
+{
+ // only color images are supperted
+ CV_Assert(image.type() == CV_8UC3);
+
+ // only this window size allowed
+ CV_Assert(image.cols == 640 && image.rows == 480);
+}
void cv::SoftCascade::detectForOctave(const int octave)
{}
\ No newline at end of file
cv::SoftCascade cascade;
ASSERT_TRUE(cascade.load(xml));
+}
+
+TEST(SoftCascade, Detect)
+{
+ std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/softcascade.xml";
+ std::cout << "PATH: "<< xml << std::endl;
+ cv::SoftCascade cascade;
+ ASSERT_TRUE(cascade.load(xml));
+
+ cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000006_0.png");
+ ASSERT_FALSE(colored.empty());
+
+ std::vector<cv::Rect> objectBoxes;
+ std::vector<cv::Rect> rois;
+ rois.push_back(cv::Rect(0, 0, 640, 480));
+ ASSERT_NO_THROW(
+ {
+ cascade.detectMultiScale(colored, rois, objectBoxes);
+ });
}
\ No newline at end of file