move ICF -> ChannelFeature

This commit is contained in:
marina.kolpakova
2013-01-30 09:34:22 +04:00
parent a01f596474
commit b4aa33b6d3
6 changed files with 194 additions and 129 deletions

View File

@@ -72,11 +72,6 @@ void sft::ICFFeaturePool::write( cv::FileStorage& fs, int index) const
fs << pool[index];
}
void sft::write(cv::FileStorage& fs, const string&, const ICF& f)
{
fs << "{" << "channel" << f.channel << "rect" << f.bb << "}";
}
sft::ICFFeaturePool::~ICFFeaturePool(){}
#if defined _WIN32 && (_WIN32 || _WIN64)
@@ -137,7 +132,7 @@ void sft::ICFFeaturePool::fill(int desired)
int ch = chRand(eng_ch);
sft::ICF f(x, y, w, h, ch);
cv::ChannelFeature f(x, y, w, h, ch);
if (std::find(pool.begin(), pool.end(),f) == pool.end())
{
@@ -147,12 +142,6 @@ void sft::ICFFeaturePool::fill(int desired)
}
}
std::ostream& sft::operator<<(std::ostream& out, const sft::ICF& m)
{
out << m.channel << " " << m.bb;
return out;
}
// ============ Dataset ============ //
namespace {
using namespace sft;

View File

@@ -50,48 +50,6 @@
#include <opencv2/softcascade/softcascade.hpp>
namespace sft
{
struct ICF
{
ICF(int x, int y, int w, int h, int ch) : bb(cv::Rect(x, y, w, h)), channel(ch) {}
bool operator ==(ICF b)
{
return bb == b.bb && channel == b.channel;
}
bool operator !=(ICF b)
{
return bb != b.bb || channel != b.channel;
}
float operator() (const cv::Mat& integrals, const cv::Size& model) const
{
int step = model.width + 1;
const int* ptr = integrals.ptr<int>(0) + (model.height * channel + bb.y) * step + bb.x;
int a = ptr[0];
int b = ptr[bb.width];
ptr += bb.height * step;
int c = ptr[bb.width];
int d = ptr[0];
return (float)(a - b + c - d);
}
private:
cv::Rect bb;
int channel;
friend void write(cv::FileStorage& fs, const std::string&, const ICF& f);
friend std::ostream& operator<<(std::ostream& out, const ICF& f);
};
void write(cv::FileStorage& fs, const std::string&, const ICF& f);
std::ostream& operator<<(std::ostream& out, const ICF& m);
using cv::FeaturePool;
using cv::Dataset;
@@ -115,7 +73,7 @@ private:
cv::Size model;
int nfeatures;
std::vector<ICF> pool;
std::vector<cv::ChannelFeature> pool;
static const unsigned int seed = 0;