Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6571195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:51:05+00:00 2026-05-25T14:51:05+00:00

I was looking for a helper function to calculate the intersection of two lines

  • 0

I was looking for a helper function to calculate the intersection of two lines in OpenCV. I have searched the API Documentation, but couldn’t find a useful resource.

Are there basic geometric helper functions for intersection/distance calculations on lines/line segments in OpenCV?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:51:06+00:00Added an answer on May 25, 2026 at 2:51 pm

    There are no function in OpenCV API to calculate lines intersection, but distance is:

    cv::Point2f start, end;
    double length = cv::norm(end - start);
    

    If you need a piece of code to calculate line intersections then here it is:

    // Finds the intersection of two lines, or returns false.
    // The lines are defined by (o1, p1) and (o2, p2).
    bool intersection(Point2f o1, Point2f p1, Point2f o2, Point2f p2,
                          Point2f &r)
    {
        Point2f x = o2 - o1;
        Point2f d1 = p1 - o1;
        Point2f d2 = p2 - o2;
    
        float cross = d1.x*d2.y - d1.y*d2.x;
        if (abs(cross) < /*EPS*/1e-8)
            return false;
    
        double t1 = (x.x * d2.y - x.y * d2.x)/cross;
        r = o1 + d1 * t1;
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for a nifty helper function/method for grepping through all defined tables, columns, stored
I've tried looking at similar problems, but could not easily find one that helped
I'm looking for a PHP date helper function that can compute like Twitter: 20
I wish to use the $html->image(...) helper function in CakePHP to output images, but
I have a helper function in a class library that creates and serves a
I am looking to pass an event to a helper function. This function will
I have two classes. Looking to be able to grab a variable that is
I am looking for a helper tool/ script that can be used to power
I'm looking to build an reusable control or custom helper for my MVC project.
I am trying to create a helper function to read a file and mock

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.