Example #1
0
void Fern::train(const cv::Mat &frame, const cv::Rect &patchRect, const bool isPositive)
{
    int leaf = getLeafIndex(frame, patchRect);
    if (isPositive == true)
    {
        leafs[leaf].increment();
    }
    else
    {
        leafs[leaf].decrement();
    }
}
Example #2
0
void Fern::train(IntegralImage *image, int patchX, int patchY, int patchW, int patchH, int patchClass) {
    // Apply all tests to find the leaf index this patch falls into
    int leaf = getLeafIndex(image, patchX, patchY, patchW, patchH);
    
    // Increment the number of positive or negative patches that fell into
    // this leaf
    if (patchClass == 0) {
        n[leaf]++;
    }
    else {
        p[leaf]++;
    }
    
    // Compute the posterior likelihood of a positive class for this leaf
    if (p[leaf] > 0) {
        posteriors[leaf] = (float)p[leaf] / (float)(p[leaf] + n[leaf]);
    }
}
Example #3
0
// Classify a given patch
double Fern::classify( cv::Mat   const & image,
                       cv::Point       & patchPt,
                       cv::Point       & patchDims)
{
   return m_posteriors[getLeafIndex(image,patchPt,patchDims)];
}
Example #4
0
double Fern::classify(const cv::Mat &frame, const cv::Rect &patchRect) const
{
    return leafs.at(getLeafIndex(frame, patchRect)).load();
}
Example #5
0
float Fern::classify(IntegralImage *image, int patchX, int patchY, int patchW, int patchH) {
    // Return the precomputed posterior likelihood of a positive class for
    // this leaf
    return posteriors[getLeafIndex(image, patchX, patchY, patchW, patchH)];
}