Click here to Skip to main content
15,665,276 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys
i need to a code for image processing in c#

i need help to find intersection point of 2 lines in image
for example this image: https://pasteboard.co/KeNReJ4.jpg
i need to use from Emgu library in c# for find this points
i have a code but i dont know how to use it
if you can write this code for me that find intersection point of lines in my image
thanks

What I have tried:

public static Vector3 Intersect(Vector3 line1V1, Vector3 line1V2, Vector3 line2V1, Vector3 line2V2)
{
    //Line1
    float A1 = line1V2.Y - line1V1.Y;
    float B1 = line1V1.X - line1V2.X;
    float C1 = A1*line1V1.X + B1*line1V1.Y;

    //Line2
    float A2 = line2V2.Y - line2V1.Y;
    float B2 = line2V1.X - line2V2.X;
    float C2 = A2 * line2V1.X + B2 * line2V1.Y;

    float det = A1*B2 - A2*B1;
    if (det == 0)
    {
        return null;//parallel lines
    }
    else
    {
        float x = (B2*C1 - B1*C2)/det;
        float y = (A1 * C2 - A2 * C1) / det;
        return new Vector3(x,y,0);
    }
}
Posted
Updated 7-Aug-21 6:15am
Comments
BillWoodruff 9-Aug-21 1:29am    
What information about the lines can you get right now ?

If you have the start and end Points for two lines, I can share C# code that will tell you whether they intersect, and, if they do intersect, the point where they intersect.

1 solution

That code has nothing to do with image processing - it's to do with finding the intersection point of two lines given their start and end points as three dimensional coordinates.
That's just simple geometry!

I can only assume that what you are trying to do is different: it's finding an intersection point of two lines in an image without having the coordinates, which means you have to find the lines on an image and then identify a coordinate at which they intersect.

I don't thank the code you found is going to help you in the least ... I'd start by thinking about exactly what you are trying to do that you think this is necessary, and start again from that instead of trying to proceed from a "random lump of internet code" that you don't understand.
 
Share this answer
 
Comments
payam mohammadi 8-Aug-21 0:46am    
i think the answer is here : https://stackoverflow.com/questions/46565975/find-intersection-point-of-two-lines-drawn-using-houghlines-opencv
but it code need to change to use in c#
BillWoodruff 9-Aug-21 1:31am    
"That's just simple geometry!" ... not so simple when you want to handle edge cases like collinearity, etc, :)

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