Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I want FindLine Function is anybody help me

C#
private Rectangle FindMarker(AtalaImage img)
{
    int numRowsToSearch = img.Height / 8; // marker is within this area
    int markerSizeThreshold = img.Width / 25; // marker is at least this big
    // eventual marker position
    int top = -1;
    int left = -1;
    int right = -1;
    int bottom = -1;

    // try to find the top of the marker, by looping through each row
    for (int y = 0; y < numRowsToSearch; ++y)
    {
        if (FindLine(img, y, markerSizeThreshold, ref left, ref right))
        {
            top = y;
            break;
        }
    }
    if (top == -1)
    {
        throw new Exception("Didn't find marker");
    }

    // find marker extents
    int expectedBottom = top + (right - left) + 10;
    bottom = expectedBottom;
    for (int y = top + 1; y < expectedBottom; ++y)
    {
        int l=-1, r=-1;
        if (FindLine(img, y, markerSizeThreshold, ref l, ref r))
        {
            if (l > right+5 || r < left-5)
            {
                throw new Exception("Marker not found");
            }
            if (l < left) left = l;
            if (r > right) right = r;
        }
        else if (y - top < markerSizeThreshold)
        {
            throw new Exception("Marker not big enough");
        }
        else
        {
            bottom = y;
            break;
        }
    }

    return new Rectangle(left, top, right - left, bottom - top);
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900