add test for soft cascade detect method
This commit is contained in:
parent
f01c5d9033
commit
b0b85f36f6
@ -493,12 +493,18 @@ protected:
|
|||||||
class CV_EXPORTS SoftCascade
|
class CV_EXPORTS SoftCascade
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! empty cascade will be created.
|
||||||
SoftCascade();
|
SoftCascade();
|
||||||
|
|
||||||
|
//! cascade will be loaded from file "filename"
|
||||||
SoftCascade( const string& filename, const float minScale = 0.4f, const float maxScale = 5.f);
|
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);
|
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:
|
protected:
|
||||||
virtual void detectForOctave(int octave);
|
virtual void detectForOctave(int octave);
|
||||||
|
@ -319,14 +319,20 @@ bool cv::SoftCascade::load( const string& filename, const float minScale, const
|
|||||||
filds = new Filds;
|
filds = new Filds;
|
||||||
Filds& flds = *filds;
|
Filds& flds = *filds;
|
||||||
if (!flds.fill(fs.getFirstTopLevelNode(), minScale, maxScale)) return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::SoftCascade::detectMultiScale(const Mat& image, const std::vector<cv::Rect>& rois, std::vector<cv::Rect>& objects,
|
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)
|
void cv::SoftCascade::detectForOctave(const int octave)
|
||||||
{}
|
{}
|
@ -48,3 +48,22 @@ TEST(SoftCascade, readCascade)
|
|||||||
ASSERT_TRUE(cascade.load(xml));
|
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);
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user