Click here to Skip to main content
15,860,861 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi , at first i'm sorry for my bad english

I want to find the corners of the football field
And then I can use it to locate the robot in the field
I used the HoughLines() functions , but have not answered

Please, if you have a sample code about, put it to me

This is the code I used:


C#
foreach (LineSegment2D l1 in lines)
{
    foreach (LineSegment2D l2 in lines)
    {
        if (Math.Abs(l1.P2.X) - Math.Abs( l1.P1.X) != 0 &&
            Math.Abs(l2.P2.X )- Math.Abs(l2.P1.X) != 0)
             
        {
            slope_l1 = Math.Abs(l1.P2.Y - l1.P1.Y) / Math.Abs(l1.P2.X - l1.P1.X);
            slope_l2 = Math.Abs(l2.P2.Y - l2.P1.Y) / Math.Abs(l2.P2.X - l2.P1.X);
 
            angle_l1 = Math.Atan(slope_l1) *180/  Math.PI;
            angle_l2 = Math.Atan(slope_l2) * 180/ Math.PI;
 
 
 
            if (
 
                Math.Abs(angle_l2 - angle_l1) > 80 && Math.Abs(angle_l2 - angle_l1) < 110))
                 
            {
               img.Draw(l1, new Bgr(Color.Yellow), 2);
            
 
            }
 
        }
    }
    this.Invoke(new Action(delegate()
    {
     
        pictureBox1.Image = img.Bitmap;
    }));


And If I change the condition to

C#
if(   Math.Abs(angle_l2 - angle_l1) > 80 && Math.Abs(angle_l2 - angle_l1) < 110)
                              && ((l1.P1 == l2.P2)|| (l1.P2==l2.P1)
                              || (l1.P1==l2.P1) ||(l1.P2 == l2.P2) ))


There was no line display


plese help me
Posted
Updated 13-Oct-12 0:35am
v2

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