Ejemplo n.º 1
2
bool TrainExample::isEqual(const ParseTree & pt) const
{    
    assert(pts().size() >= 2);

    const ParseInfo * p = pts()[0].rootNode()->parseInfo(&pts()[0]);
    const ParseInfo * p1 = pt.rootNode()->parseInfo(&pt);

    assert(p);
    assert(p1);

    return (pts()[0].dataId() == pt.dataId()) &&
           (p->c_ == p1->c_) && (p->l_ == p1->l_) &&
            (p->x_ == p1->x_) && (p->y_ == p1->y_ );
}
Ejemplo n.º 2
0
bool PtIntersector::operator()(const ParseTree &  pt, Scalar * score) const
{
    if (score) {
        *score = 0.0;
    }

    const ParseInfo * ref = reference_->rootNode()->parseInfo( reference_ );
    const ParseInfo * cur = pt.rootNode()->parseInfo( &pt );

    const int left = std::max<int>(ref->left(), cur->left());
    const int right = std::min<int>(ref->right(), cur->right());

    if (right < left) {
        return false;
    }

    const int top = std::max<int>(ref->top(), cur->top());
    const int bottom = std::min<int>(ref->bottom(), cur->bottom());

    if (bottom < top) {
        return false;
    }

    const int intersectionArea = (right - left + 1) * (bottom - top + 1);
    const int rectArea = cur->area();

    if (dividedByUnion_) {
        const int referenceArea = ref->area();
        const int unionArea = referenceArea + rectArea - intersectionArea;

        if (intersectionArea >= unionArea * threshold_) {
            if (score) {
                *score = static_cast<Scalar>(intersectionArea) / unionArea;
            }

            return true;
        }
    } else {
        if (intersectionArea >= rectArea * threshold_) {
            if (score) {
                *score = static_cast<Scalar>(intersectionArea) / rectArea;
            }

            return true;
        }
    }

    return false;
}
Ejemplo n.º 3
0
bool ParseTree::operator<(const ParseTree & pt) const
{
    return rootNode()->parseInfo(this)->score_ > pt.rootNode()->parseInfo(&pt)->score_; // for decreasing sort
}