Ejemplo n.º 1
0
int Blob::matchingArea( const Blob& blob ) const
{
    cv::Rect area;
    if( !overlappingAreaRect( blob, area ) )
        return 0;

    return area.area();
#if 0
    //minimum area rectangle containing a and b
    cv::Rect r = d->boundingRect | blob.getBoundingRect();

    cv::Mat m(r.size(), CV_8UC1);
    m = cv::Scalar(0);

    for( unsigned int i=0; i<d->contour.size(); ++i)
    {
        const cv::Point& p = d->contour[i];
        m.at<uchar>(p.x,p.y) = 1;
    }

    int count = 0;
    const std::vector<cv::Point>& contour = blob.getContour();
    for( unsigned int i=0; i<contour.size(); ++i)
    {
        const cv::Point& p = contour[i];
        if( m.at<uchar>(p.x,p.y) == 1 ) ++count;
    }
    return count;
#endif
}
Ejemplo n.º 2
0
bool Blob::overlappingAreaRect( const Blob& other, cv::Rect& area ) const
{
    const cv::Rect& rect = other.getBoundingRect();
    return overlappingArea( d->boundingRect, rect, area ) > 0;
}