Commit f7ac7399 authored by marina.kolpakova's avatar marina.kolpakova

code review fixes

parent 14ac8a52
...@@ -46,8 +46,10 @@ ...@@ -46,8 +46,10 @@
#include <opencv2/core/core.hpp> #include <opencv2/core/core.hpp>
#include <opencv2/softcascade/softcascade.hpp> #include <opencv2/softcascade/softcascade.hpp>
namespace cv {using namespace scascade;}
namespace sft namespace sft
{ {
using cv::Mat; using cv::Mat;
struct ICF; struct ICF;
......
...@@ -97,6 +97,7 @@ catch (const cv::Exception &e) \ ...@@ -97,6 +97,7 @@ catch (const cv::Exception &e) \
} }
using namespace cv; using namespace cv;
typedef cv::scascade::ChannelFeatureBuilder scascade_ChannelFeatureBuilder;
typedef vector<uchar> vector_uchar; typedef vector<uchar> vector_uchar;
typedef vector<int> vector_int; typedef vector<int> vector_int;
...@@ -125,7 +126,7 @@ typedef Ptr<DescriptorExtractor> Ptr_DescriptorExtractor; ...@@ -125,7 +126,7 @@ typedef Ptr<DescriptorExtractor> Ptr_DescriptorExtractor;
typedef Ptr<Feature2D> Ptr_Feature2D; typedef Ptr<Feature2D> Ptr_Feature2D;
typedef Ptr<DescriptorMatcher> Ptr_DescriptorMatcher; typedef Ptr<DescriptorMatcher> Ptr_DescriptorMatcher;
typedef Ptr<ChannelFeatureBuilder> Ptr_ChannelFeatureBuilder; typedef Ptr<cv::scascade::ChannelFeatureBuilder> Ptr_ChannelFeatureBuilder;
typedef SimpleBlobDetector::Params SimpleBlobDetector_Params; typedef SimpleBlobDetector::Params SimpleBlobDetector_Params;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
namespace cv { namespace cv { namespace scascade {
// Representation of detectors result. // Representation of detectors result.
struct CV_EXPORTS Detection struct CV_EXPORTS Detection
...@@ -122,7 +122,7 @@ std::ostream& operator<<(std::ostream& out, const ChannelFeature& m); ...@@ -122,7 +122,7 @@ std::ostream& operator<<(std::ostream& out, const ChannelFeature& m);
// Public Interface for Integral Channel Feature. // Public Interface for Integral Channel Feature.
// ========================================================================== // // ========================================================================== //
class CV_EXPORTS_W ChannelFeatureBuilder : public Algorithm class CV_EXPORTS_W ChannelFeatureBuilder : public cv::Algorithm
{ {
public: public:
virtual ~ChannelFeatureBuilder(); virtual ~ChannelFeatureBuilder();
...@@ -136,7 +136,7 @@ public: ...@@ -136,7 +136,7 @@ public:
// ========================================================================== // // ========================================================================== //
// Implementation of soft (stageless) cascaded detector. // Implementation of soft (stageless) cascaded detector.
// ========================================================================== // // ========================================================================== //
class CV_EXPORTS_W SoftCascadeDetector : public Algorithm class CV_EXPORTS_W SoftCascadeDetector : public cv::Algorithm
{ {
public: public:
...@@ -186,7 +186,7 @@ private: ...@@ -186,7 +186,7 @@ private:
// ========================================================================== // // ========================================================================== //
// Public Interface for singe soft (stageless) cascade octave training. // Public Interface for singe soft (stageless) cascade octave training.
// ========================================================================== // // ========================================================================== //
class CV_EXPORTS SoftCascadeOctave : public Algorithm class CV_EXPORTS SoftCascadeOctave : public cv::Algorithm
{ {
public: public:
enum enum
...@@ -211,6 +211,6 @@ public: ...@@ -211,6 +211,6 @@ public:
CV_EXPORTS bool initModule_softcascade(void); CV_EXPORTS bool initModule_softcascade(void);
} } }
#endif #endif
\ No newline at end of file
...@@ -24,7 +24,7 @@ def convert2detections(rects, confs, crop_factor = 0.125): ...@@ -24,7 +24,7 @@ def convert2detections(rects, confs, crop_factor = 0.125):
""" Create new instance of soft cascade.""" """ Create new instance of soft cascade."""
def cascade(min_scale, max_scale, nscales, f): def cascade(min_scale, max_scale, nscales, f):
# where we use nms cv::SoftCascadeDetector::DOLLAR == 2 # where we use nms cv::SoftCascadeDetector::DOLLAR == 2
c = cv2.SoftCascadeDetector(min_scale, max_scale, nscales, 2) c = cv2.scascade_SoftCascadeDetector(min_scale, max_scale, nscales, 2)
xml = cv2.FileStorage(f, 0) xml = cv2.FileStorage(f, 0)
dom = xml.getFirstTopLevelNode() dom = xml.getFirstTopLevelNode()
assert c.load(dom) assert c.load(dom)
......
...@@ -10,7 +10,7 @@ typedef perf::TestBaseWithParam<fixture> detect; ...@@ -10,7 +10,7 @@ typedef perf::TestBaseWithParam<fixture> detect;
namespace { namespace {
void extractRacts(std::vector<cv::Detection> objectBoxes, std::vector<Rect>& rects) void extractRacts(std::vector<cv::scascade::Detection> objectBoxes, std::vector<Rect>& rects)
{ {
rects.clear(); rects.clear();
for (int i = 0; i < (int)objectBoxes.size(); ++i) for (int i = 0; i < (int)objectBoxes.size(); ++i)
...@@ -26,12 +26,12 @@ PERF_TEST_P(detect, SoftCascadeDetector, ...@@ -26,12 +26,12 @@ PERF_TEST_P(detect, SoftCascadeDetector,
cv::Mat colored = cv::imread(getDataPath(get<1>(GetParam()))); cv::Mat colored = cv::imread(getDataPath(get<1>(GetParam())));
ASSERT_FALSE(colored.empty()); ASSERT_FALSE(colored.empty());
cv::SoftCascadeDetector cascade; cv::scascade::SoftCascadeDetector cascade;
cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ); cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened()); ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
std::vector<cv::Detection> objectBoxes; std::vector<cv::scascade::Detection> objectBoxes;
cascade.detect(colored, cv::noArray(), objectBoxes); cascade.detect(colored, cv::noArray(), objectBoxes);
TEST_CYCLE() TEST_CYCLE()
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
namespace { namespace {
class ICFBuilder : public cv::ChannelFeatureBuilder class ICFBuilder : public ChannelFeatureBuilder
{ {
virtual ~ICFBuilder() {} virtual ~ICFBuilder() {}
virtual cv::AlgorithmInfo* info() const; virtual cv::AlgorithmInfo* info() const;
...@@ -109,29 +109,29 @@ class ICFBuilder : public cv::ChannelFeatureBuilder ...@@ -109,29 +109,29 @@ class ICFBuilder : public cv::ChannelFeatureBuilder
CV_INIT_ALGORITHM(ICFBuilder, "ChannelFeatureBuilder.ICFBuilder", ); CV_INIT_ALGORITHM(ICFBuilder, "ChannelFeatureBuilder.ICFBuilder", );
cv::ChannelFeatureBuilder::~ChannelFeatureBuilder() {} cv::scascade::ChannelFeatureBuilder::~ChannelFeatureBuilder() {}
cv::Ptr<cv::ChannelFeatureBuilder> cv::ChannelFeatureBuilder::create() cv::Ptr<ChannelFeatureBuilder> ChannelFeatureBuilder::create()
{ {
cv::Ptr<cv::ChannelFeatureBuilder> builder(new ICFBuilder()); cv::Ptr<ChannelFeatureBuilder> builder(new ICFBuilder());
return builder; return builder;
} }
cv::ChannelFeature::ChannelFeature(int x, int y, int w, int h, int ch) cv::scascade::ChannelFeature::ChannelFeature(int x, int y, int w, int h, int ch)
: bb(cv::Rect(x, y, w, h)), channel(ch) {} : bb(cv::Rect(x, y, w, h)), channel(ch) {}
bool cv::ChannelFeature::operator ==(cv::ChannelFeature b) bool ChannelFeature::operator ==(ChannelFeature b)
{ {
return bb == b.bb && channel == b.channel; return bb == b.bb && channel == b.channel;
} }
bool cv::ChannelFeature::operator !=(cv::ChannelFeature b) bool ChannelFeature::operator !=(ChannelFeature b)
{ {
return bb != b.bb || channel != b.channel; return bb != b.bb || channel != b.channel;
} }
float cv::ChannelFeature::operator() (const cv::Mat& integrals, const cv::Size& model) const float cv::scascade::ChannelFeature::operator() (const cv::Mat& integrals, const cv::Size& model) const
{ {
int step = model.width + 1; int step = model.width + 1;
...@@ -148,22 +148,22 @@ float cv::ChannelFeature::operator() (const cv::Mat& integrals, const cv::Size& ...@@ -148,22 +148,22 @@ float cv::ChannelFeature::operator() (const cv::Mat& integrals, const cv::Size&
return (float)(a - b + c - d); return (float)(a - b + c - d);
} }
void cv::write(cv::FileStorage& fs, const string&, const cv::ChannelFeature& f) void cv::scascade::write(cv::FileStorage& fs, const string&, const ChannelFeature& f)
{ {
fs << "{" << "channel" << f.channel << "rect" << f.bb << "}"; fs << "{" << "channel" << f.channel << "rect" << f.bb << "}";
} }
std::ostream& cv::operator<<(std::ostream& out, const cv::ChannelFeature& m) std::ostream& cv::scascade::operator<<(std::ostream& out, const ChannelFeature& m)
{ {
out << m.channel << " " << m.bb; out << m.channel << " " << m.bb;
return out; return out;
} }
cv::ChannelFeature::~ChannelFeature(){} cv::scascade::ChannelFeature::~ChannelFeature(){}
namespace { namespace {
class ChannelFeaturePool : public cv::FeaturePool class ChannelFeaturePool : public FeaturePool
{ {
public: public:
ChannelFeaturePool(cv::Size m, int n) : FeaturePool(), model(m) ChannelFeaturePool(cv::Size m, int n) : FeaturePool(), model(m)
...@@ -183,7 +183,7 @@ private: ...@@ -183,7 +183,7 @@ private:
void fill(int desired); void fill(int desired);
cv::Size model; cv::Size model;
std::vector<cv::ChannelFeature> pool; std::vector<ChannelFeature> pool;
enum { N_CHANNELS = 10 }; enum { N_CHANNELS = 10 };
}; };
...@@ -235,7 +235,7 @@ void ChannelFeaturePool::fill(int desired) ...@@ -235,7 +235,7 @@ void ChannelFeaturePool::fill(int desired)
int ch = chRand(eng_ch); int ch = chRand(eng_ch);
cv::ChannelFeature f(x, y, w, h, ch); ChannelFeature f(x, y, w, h, ch);
if (std::find(pool.begin(), pool.end(),f) == pool.end()) if (std::find(pool.begin(), pool.end(),f) == pool.end())
{ {
...@@ -246,8 +246,8 @@ void ChannelFeaturePool::fill(int desired) ...@@ -246,8 +246,8 @@ void ChannelFeaturePool::fill(int desired)
} }
cv::Ptr<cv::FeaturePool> cv::FeaturePool::create(const cv::Size& model, int nfeatures) cv::Ptr<FeaturePool> cv::scascade::FeaturePool::create(const cv::Size& model, int nfeatures)
{ {
cv::Ptr<cv::FeaturePool> pool(new ChannelFeaturePool(model, nfeatures)); cv::Ptr<FeaturePool> pool(new ChannelFeaturePool(model, nfeatures));
return pool; return pool;
} }
...@@ -55,4 +55,6 @@ ...@@ -55,4 +55,6 @@
#include "opencv2/ml/ml.hpp" #include "opencv2/ml/ml.hpp"
#include "_random.hpp" #include "_random.hpp"
using namespace cv::scascade;
#endif #endif
...@@ -44,19 +44,17 @@ ...@@ -44,19 +44,17 @@
#include <queue> #include <queue>
#include <string> #include <string>
using cv::Dataset;
using cv::FeaturePool;
using cv::InputArray; using cv::InputArray;
using cv::OutputArray; using cv::OutputArray;
using cv::Mat; using cv::Mat;
cv::FeaturePool::~FeaturePool(){} cv::scascade::FeaturePool::~FeaturePool(){}
cv::Dataset::~Dataset(){} cv::scascade::Dataset::~Dataset(){}
namespace { namespace {
class BoostedSoftCascadeOctave : public cv::Boost, public cv::SoftCascadeOctave class BoostedSoftCascadeOctave : public cv::Boost, public SoftCascadeOctave
{ {
public: public:
...@@ -96,7 +94,7 @@ private: ...@@ -96,7 +94,7 @@ private:
Mat trainData; Mat trainData;
cv::Ptr<cv::ChannelFeatureBuilder> builder; cv::Ptr<ChannelFeatureBuilder> builder;
}; };
BoostedSoftCascadeOctave::BoostedSoftCascadeOctave(cv::Rect bb, int np, int nn, int ls, int shr, int poolSize) BoostedSoftCascadeOctave::BoostedSoftCascadeOctave(cv::Rect bb, int np, int nn, int ls, int shr, int poolSize)
...@@ -128,7 +126,7 @@ BoostedSoftCascadeOctave::BoostedSoftCascadeOctave(cv::Rect bb, int np, int nn, ...@@ -128,7 +126,7 @@ BoostedSoftCascadeOctave::BoostedSoftCascadeOctave(cv::Rect bb, int np, int nn,
params = _params; params = _params;
builder = cv::ChannelFeatureBuilder::create(); builder = ChannelFeatureBuilder::create();
int w = boundingBox.width; int w = boundingBox.width;
int h = boundingBox.height; int h = boundingBox.height;
...@@ -195,7 +193,7 @@ void BoostedSoftCascadeOctave::processPositives(const Dataset* dataset) ...@@ -195,7 +193,7 @@ void BoostedSoftCascadeOctave::processPositives(const Dataset* dataset)
{ {
int h = boundingBox.height; int h = boundingBox.height;
cv::ChannelFeatureBuilder& _builder = *builder; ChannelFeatureBuilder& _builder = *builder;
int total = 0; int total = 0;
for (int curr = 0; curr < dataset->available( Dataset::POSITIVE); ++curr) for (int curr = 0; curr < dataset->available( Dataset::POSITIVE); ++curr)
...@@ -228,7 +226,7 @@ void BoostedSoftCascadeOctave::generateNegatives(const Dataset* dataset) ...@@ -228,7 +226,7 @@ void BoostedSoftCascadeOctave::generateNegatives(const Dataset* dataset)
int total = 0; int total = 0;
Mat sum; Mat sum;
cv::ChannelFeatureBuilder& _builder = *builder; ChannelFeatureBuilder& _builder = *builder;
for (int i = npositives; i < nnegatives + npositives; ++total) for (int i = npositives; i < nnegatives + npositives; ++total)
{ {
int curr = iRand(idxEng); int curr = iRand(idxEng);
...@@ -441,12 +439,12 @@ void BoostedSoftCascadeOctave::write( CvFileStorage* fs, std::string _name) cons ...@@ -441,12 +439,12 @@ void BoostedSoftCascadeOctave::write( CvFileStorage* fs, std::string _name) cons
CV_INIT_ALGORITHM(BoostedSoftCascadeOctave, "SoftCascadeOctave.BoostedSoftCascadeOctave", ); CV_INIT_ALGORITHM(BoostedSoftCascadeOctave, "SoftCascadeOctave.BoostedSoftCascadeOctave", );
cv::SoftCascadeOctave::~SoftCascadeOctave(){} cv::scascade::SoftCascadeOctave::~SoftCascadeOctave(){}
cv::Ptr<cv::SoftCascadeOctave> cv::SoftCascadeOctave::create(cv::Rect boundingBox, int npositives, int nnegatives, cv::Ptr<SoftCascadeOctave> cv::scascade::SoftCascadeOctave::create(cv::Rect boundingBox, int npositives, int nnegatives,
int logScale, int shrinkage, int poolSize) int logScale, int shrinkage, int poolSize)
{ {
cv::Ptr<cv::SoftCascadeOctave> octave( cv::Ptr<SoftCascadeOctave> octave(
new BoostedSoftCascadeOctave(boundingBox, npositives, nnegatives, logScale, shrinkage, poolSize)); new BoostedSoftCascadeOctave(boundingBox, npositives, nnegatives, logScale, shrinkage, poolSize));
return octave; return octave;
} }
...@@ -145,13 +145,13 @@ struct Level ...@@ -145,13 +145,13 @@ struct Level
scaleshift = static_cast<int>(relScale * (1 << 16)); scaleshift = static_cast<int>(relScale * (1 << 16));
} }
void addDetection(const int x, const int y, float confidence, std::vector<cv::Detection>& detections) const void addDetection(const int x, const int y, float confidence, std::vector<Detection>& detections) const
{ {
// fix me // fix me
int shrinkage = 4;//(*octave).shrinkage; int shrinkage = 4;//(*octave).shrinkage;
cv::Rect rect(cvRound(x * shrinkage), cvRound(y * shrinkage), objSize.width, objSize.height); cv::Rect rect(cvRound(x * shrinkage), cvRound(y * shrinkage), objSize.width, objSize.height);
detections.push_back(cv::Detection(rect, confidence)); detections.push_back(Detection(rect, confidence));
} }
float rescale(cv::Rect& scaledRect, const float threshold, int idx) const float rescale(cv::Rect& scaledRect, const float threshold, int idx) const
...@@ -177,13 +177,13 @@ struct ChannelStorage ...@@ -177,13 +177,13 @@ struct ChannelStorage
int step; int step;
int model_height; int model_height;
cv::Ptr<cv::ChannelFeatureBuilder> builder; cv::Ptr<ChannelFeatureBuilder> builder;
enum {HOG_BINS = 6, HOG_LUV_BINS = 10}; enum {HOG_BINS = 6, HOG_LUV_BINS = 10};
ChannelStorage(const cv::Mat& colored, int shr) : shrinkage(shr) ChannelStorage(const cv::Mat& colored, int shr) : shrinkage(shr)
{ {
builder = cv::ChannelFeatureBuilder::create(); builder = ChannelFeatureBuilder::create();
(*builder)(colored, hog); (*builder)(colored, hog);
step = hog.step1(); step = hog.step1();
...@@ -205,7 +205,7 @@ struct ChannelStorage ...@@ -205,7 +205,7 @@ struct ChannelStorage
} }
struct cv::SoftCascadeDetector::Fields struct SoftCascadeDetector::Fields
{ {
float minScale; float minScale;
float maxScale; float maxScale;
...@@ -409,17 +409,17 @@ struct cv::SoftCascadeDetector::Fields ...@@ -409,17 +409,17 @@ struct cv::SoftCascadeDetector::Fields
} }
}; };
cv::SoftCascadeDetector::SoftCascadeDetector(const double mins, const double maxs, const int nsc, const int rej) SoftCascadeDetector::SoftCascadeDetector(const double mins, const double maxs, const int nsc, const int rej)
: fields(0), minScale(mins), maxScale(maxs), scales(nsc), rejCriteria(rej) {} : fields(0), minScale(mins), maxScale(maxs), scales(nsc), rejCriteria(rej) {}
cv::SoftCascadeDetector::~SoftCascadeDetector() { delete fields;} SoftCascadeDetector::~SoftCascadeDetector() { delete fields;}
void cv::SoftCascadeDetector::read(const FileNode& fn) void SoftCascadeDetector::read(const FileNode& fn)
{ {
Algorithm::read(fn); Algorithm::read(fn);
} }
bool cv::SoftCascadeDetector::load(const FileNode& fn) bool SoftCascadeDetector::load(const FileNode& fn)
{ {
if (fields) delete fields; if (fields) delete fields;
...@@ -429,12 +429,12 @@ bool cv::SoftCascadeDetector::load(const FileNode& fn) ...@@ -429,12 +429,12 @@ bool cv::SoftCascadeDetector::load(const FileNode& fn)
namespace { namespace {
typedef std::vector<cv::Detection> dvector; typedef std::vector<Detection> dvector;
struct ConfidenceGt struct ConfidenceGt
{ {
bool operator()(const cv::Detection& a, const cv::Detection& b) const bool operator()(const Detection& a, const Detection& b) const
{ {
return a.confidence > b.confidence; return a.confidence > b.confidence;
} }
...@@ -455,10 +455,10 @@ void DollarNMS(dvector& objects) ...@@ -455,10 +455,10 @@ void DollarNMS(dvector& objects)
for (dvector::iterator dIt = objects.begin(); dIt != objects.end(); ++dIt) for (dvector::iterator dIt = objects.begin(); dIt != objects.end(); ++dIt)
{ {
const cv::Detection &a = *dIt; const Detection &a = *dIt;
for (dvector::iterator next = dIt + 1; next != objects.end(); ) for (dvector::iterator next = dIt + 1; next != objects.end(); )
{ {
const cv::Detection &b = *next; const Detection &b = *next;
const float ovl = overlap(a.bb, b.bb) / std::min(a.bb.area(), b.bb.area()); const float ovl = overlap(a.bb, b.bb) / std::min(a.bb.area(), b.bb.area());
...@@ -470,15 +470,15 @@ void DollarNMS(dvector& objects) ...@@ -470,15 +470,15 @@ void DollarNMS(dvector& objects)
} }
} }
static void suppress(int type, std::vector<cv::Detection>& objects) static void suppress(int type, std::vector<Detection>& objects)
{ {
CV_Assert(type == cv::SoftCascadeDetector::DOLLAR); CV_Assert(type == SoftCascadeDetector::DOLLAR);
DollarNMS(objects); DollarNMS(objects);
} }
} }
void cv::SoftCascadeDetector::detectNoRoi(const cv::Mat& image, std::vector<Detection>& objects) const void SoftCascadeDetector::detectNoRoi(const cv::Mat& image, std::vector<Detection>& objects) const
{ {
Fields& fld = *fields; Fields& fld = *fields;
// create integrals // create integrals
...@@ -505,7 +505,7 @@ void cv::SoftCascadeDetector::detectNoRoi(const cv::Mat& image, std::vector<Dete ...@@ -505,7 +505,7 @@ void cv::SoftCascadeDetector::detectNoRoi(const cv::Mat& image, std::vector<Dete
// if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects); // if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects);
} }
void cv::SoftCascadeDetector::detect(cv::InputArray _image, cv::InputArray _rois, std::vector<Detection>& objects) const void SoftCascadeDetector::detect(cv::InputArray _image, cv::InputArray _rois, std::vector<Detection>& objects) const
{ {
// only color images are suppered // only color images are suppered
cv::Mat image = _image.getMat(); cv::Mat image = _image.getMat();
...@@ -557,7 +557,7 @@ void cv::SoftCascadeDetector::detect(cv::InputArray _image, cv::InputArray _rois ...@@ -557,7 +557,7 @@ void cv::SoftCascadeDetector::detect(cv::InputArray _image, cv::InputArray _rois
if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects); if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects);
} }
void cv::SoftCascadeDetector::detect(InputArray _image, InputArray _rois, OutputArray _rects, OutputArray _confs) const void SoftCascadeDetector::detect(InputArray _image, InputArray _rois, OutputArray _rects, OutputArray _confs) const
{ {
std::vector<Detection> objects; std::vector<Detection> objects;
detect( _image, _rois, objects); detect( _image, _rois, objects);
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "precomp.hpp" #include "precomp.hpp"
namespace cv namespace cv { namespace scascade
{ {
CV_INIT_ALGORITHM(SoftCascadeDetector, "SoftCascade.SoftCascadeDetector", CV_INIT_ALGORITHM(SoftCascadeDetector, "SoftCascade.SoftCascadeDetector",
...@@ -58,4 +58,4 @@ bool initModule_softcascade(void) ...@@ -58,4 +58,4 @@ bool initModule_softcascade(void)
return (sc1->info() != 0); return (sc1->info() != 0);
} }
} } }
\ No newline at end of file \ No newline at end of file
...@@ -44,13 +44,13 @@ ...@@ -44,13 +44,13 @@
TEST(ChannelFeatureBuilderTest, info) TEST(ChannelFeatureBuilderTest, info)
{ {
cv::Ptr<cv::ChannelFeatureBuilder> builder = cv::ChannelFeatureBuilder::create(); cv::Ptr<cv::scascade::ChannelFeatureBuilder> builder = cv::scascade::ChannelFeatureBuilder::create();
ASSERT_TRUE(builder->info() != 0); ASSERT_TRUE(builder->info() != 0);
} }
TEST(ChannelFeatureBuilderTest, compute) TEST(ChannelFeatureBuilderTest, compute)
{ {
cv::Ptr<cv::ChannelFeatureBuilder> builder = cv::ChannelFeatureBuilder::create(); cv::Ptr<cv::scascade::ChannelFeatureBuilder> builder = cv::scascade::ChannelFeatureBuilder::create();
cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png"); cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png");
cv::Mat ints; cv::Mat ints;
......
...@@ -44,11 +44,12 @@ ...@@ -44,11 +44,12 @@
#include <fstream> #include <fstream>
#include "test_precomp.hpp" #include "test_precomp.hpp"
typedef cv::scascade::Detection Detection;
TEST(SoftCascadeDetector, readCascade) TEST(SoftCascadeDetector, readCascade)
{ {
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml"; std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
cv::SoftCascadeDetector cascade; cv::scascade::SoftCascadeDetector cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ); cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened()); ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
...@@ -56,9 +57,8 @@ TEST(SoftCascadeDetector, readCascade) ...@@ -56,9 +57,8 @@ TEST(SoftCascadeDetector, readCascade)
TEST(SoftCascadeDetector, detect) TEST(SoftCascadeDetector, detect)
{ {
typedef cv::Detection Detection;
std::string xml = cvtest::TS::ptr()->get_data_path()+ "cascadeandhog/cascades/inria_caltech-17.01.2013.xml"; std::string xml = cvtest::TS::ptr()->get_data_path()+ "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
cv::SoftCascadeDetector cascade; cv::scascade::SoftCascadeDetector cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ); cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
...@@ -73,9 +73,8 @@ TEST(SoftCascadeDetector, detect) ...@@ -73,9 +73,8 @@ TEST(SoftCascadeDetector, detect)
TEST(SoftCascadeDetector, detectSeparate) TEST(SoftCascadeDetector, detectSeparate)
{ {
typedef cv::Detection Detection;
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml"; std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
cv::SoftCascadeDetector cascade; cv::scascade::SoftCascadeDetector cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ); cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
...@@ -90,9 +89,8 @@ TEST(SoftCascadeDetector, detectSeparate) ...@@ -90,9 +89,8 @@ TEST(SoftCascadeDetector, detectSeparate)
TEST(SoftCascadeDetector, detectRoi) TEST(SoftCascadeDetector, detectRoi)
{ {
typedef cv::Detection Detection;
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml"; std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
cv::SoftCascadeDetector cascade; cv::scascade::SoftCascadeDetector cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ); cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
...@@ -109,9 +107,8 @@ TEST(SoftCascadeDetector, detectRoi) ...@@ -109,9 +107,8 @@ TEST(SoftCascadeDetector, detectRoi)
TEST(SoftCascadeDetector, detectNoRoi) TEST(SoftCascadeDetector, detectNoRoi)
{ {
typedef cv::Detection Detection;
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml"; std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
cv::SoftCascadeDetector cascade; cv::scascade::SoftCascadeDetector cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ); cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
...@@ -128,9 +125,8 @@ TEST(SoftCascadeDetector, detectNoRoi) ...@@ -128,9 +125,8 @@ TEST(SoftCascadeDetector, detectNoRoi)
TEST(SoftCascadeDetector, detectEmptyRoi) TEST(SoftCascadeDetector, detectEmptyRoi)
{ {
typedef cv::Detection Detection;
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml"; std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
cv::SoftCascadeDetector cascade; cv::scascade::SoftCascadeDetector cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ); cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode())); ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
......
...@@ -58,7 +58,7 @@ using namespace std; ...@@ -58,7 +58,7 @@ using namespace std;
namespace { namespace {
typedef vector<string> svector; typedef vector<string> svector;
class ScaledDataset : public cv::Dataset class ScaledDataset : public cv::scascade::Dataset
{ {
public: public:
ScaledDataset(const string& path, const int octave); ScaledDataset(const string& path, const int octave);
...@@ -210,7 +210,7 @@ TEST(DISABLED_SoftCascade, training) ...@@ -210,7 +210,7 @@ TEST(DISABLED_SoftCascade, training)
float octave = powf(2.f, (float)(*it)); float octave = powf(2.f, (float)(*it));
cv::Size model = cv::Size( cvRound(64 * octave) / shrinkage, cvRound(128 * octave) / shrinkage ); cv::Size model = cv::Size( cvRound(64 * octave) / shrinkage, cvRound(128 * octave) / shrinkage );
cv::Ptr<cv::FeaturePool> pool = cv::FeaturePool::create(model, nfeatures); cv::Ptr<cv::scascade::FeaturePool> pool = cv::scascade::FeaturePool::create(model, nfeatures);
nfeatures = pool->size(); nfeatures = pool->size();
int npositives = 20; int npositives = 20;
int nnegatives = 40; int nnegatives = 40;
...@@ -218,7 +218,7 @@ TEST(DISABLED_SoftCascade, training) ...@@ -218,7 +218,7 @@ TEST(DISABLED_SoftCascade, training)
cv::Rect boundingBox = cv::Rect( cvRound(20 * octave), cvRound(20 * octave), cv::Rect boundingBox = cv::Rect( cvRound(20 * octave), cvRound(20 * octave),
cvRound(64 * octave), cvRound(128 * octave)); cvRound(64 * octave), cvRound(128 * octave));
typedef cv::SoftCascadeOctave Octave; typedef cv::scascade::SoftCascadeOctave Octave;
cv::Ptr<Octave> boost = Octave::create(boundingBox, npositives, nnegatives, *it, shrinkage, nfeatures); cv::Ptr<Octave> boost = Octave::create(boundingBox, npositives, nnegatives, *it, shrinkage, nfeatures);
std::string path = cvtest::TS::ptr()->get_data_path() + "softcascade/sample_training_set"; std::string path = cvtest::TS::ptr()->get_data_path() + "softcascade/sample_training_set";
......
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