|
|
|
@ -85,13 +85,6 @@ sft::Octave::~Octave(){} |
|
|
|
|
bool sft::Octave::train( const cv::Mat& _trainData, const cv::Mat& _responses, const cv::Mat& varIdx, |
|
|
|
|
const cv::Mat& sampleIdx, const cv::Mat& varType, const cv::Mat& missingDataMask) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// std::cout << "WARNING: sampleIdx " << sampleIdx << std::endl;
|
|
|
|
|
// std::cout << "WARNING: trainData " << _trainData << std::endl;
|
|
|
|
|
// std::cout << "WARNING: _responses " << _responses << std::endl;
|
|
|
|
|
// std::cout << "WARNING: varIdx" << varIdx << std::endl;
|
|
|
|
|
// std::cout << "WARNING: varType" << varType << std::endl;
|
|
|
|
|
|
|
|
|
|
bool update = false; |
|
|
|
|
return cv::Boost::train(_trainData, CV_COL_SAMPLE, _responses, varIdx, sampleIdx, varType, missingDataMask, params, |
|
|
|
|
update); |
|
|
|
@ -119,10 +112,6 @@ void sft::Octave::setRejectThresholds(cv::Mat& thresholds) |
|
|
|
|
mptr[si] = cv::saturate_cast<uchar>((uint)( (responses.ptr<float>(si)[0] == 1.f) && (decision == 1.f))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// std::cout << "WARNING: responses " << responses << std::endl;
|
|
|
|
|
// std::cout << "WARNING: desisions " << desisions << std::endl;
|
|
|
|
|
// std::cout << "WARNING: ppmask " << ppmask << std::endl;
|
|
|
|
|
|
|
|
|
|
int weaks = weak->total; |
|
|
|
|
thresholds.create(1, weaks, CV_64FC1); |
|
|
|
|
double* thptr = thresholds.ptr<double>(0); |
|
|
|
@ -144,10 +133,7 @@ void sft::Octave::setRejectThresholds(cv::Mat& thresholds) |
|
|
|
|
double mintrace = 0.; |
|
|
|
|
cv::minMaxLoc(traces.row(w), &mintrace); |
|
|
|
|
thptr[w] = mintrace; |
|
|
|
|
// std::cout << "mintrace " << mintrace << std::endl << traces.colRange(0, npositives).rowRange(w, w + 1) << std::endl << std::endl << std::endl << std::endl;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::cout << "WARNING: thresholds " << thresholds << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
@ -211,8 +197,6 @@ public: |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ToDo: parallelize it, fix curring
|
|
|
|
|
// ToDo: sunch model size and shrinced model size usage/ Now model size mean already shrinked model
|
|
|
|
|
void sft::Octave::processPositives(const Dataset& dataset, const FeaturePool& pool) |
|
|
|
|
{ |
|
|
|
|
Preprocessor prepocessor(shrinkage); |
|
|
|
@ -227,8 +211,6 @@ void sft::Octave::processPositives(const Dataset& dataset, const FeaturePool& po |
|
|
|
|
{ |
|
|
|
|
const string& curr = *it; |
|
|
|
|
|
|
|
|
|
// dprintf("Process candidate positive image %s\n", curr.c_str());
|
|
|
|
|
|
|
|
|
|
cv::Mat sample = cv::imread(curr); |
|
|
|
|
|
|
|
|
|
cv::Mat channels = integrals.row(total).reshape(0, h / shrinkage * 10 + 1); |
|
|
|
@ -266,9 +248,6 @@ void sft::Octave::generateNegatives(const Dataset& dataset) |
|
|
|
|
{ |
|
|
|
|
int curr = iRand(idxEng); |
|
|
|
|
|
|
|
|
|
// dprintf("View %d-th sample\n", curr);
|
|
|
|
|
// dprintf("Process %s\n", dataset.neg[curr].c_str());
|
|
|
|
|
|
|
|
|
|
Mat frame = cv::imread(dataset.neg[curr]); |
|
|
|
|
|
|
|
|
|
int maxW = frame.cols - 2 * boundingBox.x - boundingBox.width; |
|
|
|
@ -352,7 +331,7 @@ void sft::Octave::traverse(const CvBoostTree* tree, cv::FileStorage& fs, int& nf |
|
|
|
|
|
|
|
|
|
fs << "leafValues" << "["; |
|
|
|
|
for (int ni = 0; ni < -leafValIdx; ni++) |
|
|
|
|
fs << leafs[ni];//( (!th) ? leafs[ni] : (sgn(leafs[ni]) * *th));
|
|
|
|
|
fs << leafs[ni]; |
|
|
|
|
fs << "]"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -447,19 +426,6 @@ bool sft::Octave::train(const Dataset& dataset, const FeaturePool& pool, int wea |
|
|
|
|
bool ok = train(trainData, responses, varIdx, sampleIdx, varType, missingMask); |
|
|
|
|
if (!ok) |
|
|
|
|
std::cout << "ERROR: tree can not be trained " << std::endl; |
|
|
|
|
|
|
|
|
|
#if defined SELF_TEST |
|
|
|
|
cv::Mat a(1, nfeatures, CV_32FC1); |
|
|
|
|
cv::Mat votes(1, cvSliceLength( CV_WHOLE_SEQ, weak ), CV_32FC1, cv::Scalar::all(0)); |
|
|
|
|
|
|
|
|
|
// std::cout << a.cols << " " << a.rows << " !!!!!!!!!!! " << data->var_all << std::endl;
|
|
|
|
|
for (int si = 0; si < nsamples; ++si) |
|
|
|
|
{ |
|
|
|
|
// trainData.col(si).copyTo(a.reshape(0,trainData.rows));
|
|
|
|
|
float desision = predict(trainData.col(si), votes, false, true); |
|
|
|
|
// std::cout << "desision " << desision << " class " << responses.at<float>(si, 0) << votes <<std::endl;
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
return ok; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|