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 6855313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:44:34+00:00 2026-05-27T01:44:34+00:00

For a group project, we are attempting to make a game, where functions are

  • 0

For a group project, we are attempting to make a game, where functions are executed whenever a player forms a set of specific hand gestures in front of a camera. To process the images, we are using Open-CV 2.3.

During the image-processing we are trying to find the length between two points.
We already know this can be done very easily with Pythagoras law, though it is known that Pythagoras law requires much computer power, and we wish to do this as low-resource as possible.

We wish to know if there exist any build-in function within Open-CV or standard library for C++, which can handle low-resource calculations of the distance between two points.
We have the coordinates for the points, which are in pixel values (Of course).

Extra info:
Previous experience have taught us, that OpenCV and other libraries are heavily optimized. As an example, we attempted to change the RGB values of the live image feed from the camera with a for loop, going through each pixel. This provided with a low frame-rate output. Instead we decided to use an Open-CV build-in function instead, which instead gave us a high frame-rate output.

  • 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-27T01:44:34+00:00Added an answer on May 27, 2026 at 1:44 am

    As you correctly pointed out, there’s an OpenCV function that does some of your work 🙂

    (Also check the other way)

    It is called magnitude() and it calculates the distance for you. And if you have a vector of more than 4 vectors to calculate distances, it will use SSE (i think) to make it faster.

    Now, the problem is that it only calculate the square of the powers, and you have to do by hand differences. (check the documentation). But if you do them also using OpenCV functions it should be fast.

    Mat pts1(nPts, 1, CV_8UC2), pts2(nPts, 1, CV_8UC2);
    // populate them
    Mat diffPts = pts1-pts2;
    Mat ptsx, ptsy;
    // split your points in x and y vectors. maybe separate them from start
    Mat dist;
    magnitude(ptsx, ptsy, dist); // voila!
    

    The other way is to use a very fast sqrt:

    // 15 times faster than the classical float sqrt. 
    // Reasonably accurate up to root(32500)
    // Source: http://supp.iar.com/FilesPublic/SUPPORT/000419/AN-G-002.pdf
    
    unsigned int root(unsigned int x){
        unsigned int a,b;
        b     = x;
        a = x = 0x3f;
        x     = b/x;
        a = x = (x+a)>>1;
        x     = b/x;
        a = x = (x+a)>>1;
        x     = b/x;
        x     = (x+a)>>1;
        return(x);  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a group project for class and we are trying out
I have put some aliases in my .bashrc to open a group of project
I work with my student group on a project : We have some problems
A project that a group of mine is starting is going to be focused
A group of us are working on a project which we built with .NET
I remember working on a project with a group of developers and they always
I have an Xcode project with the following group structure: ProjectName/ Classes/ class1.h class1.m
I'm just curious if any project exists that attempts to group all (or most)
I manage a small group and I'd keep my work breakdown in project. However,
I've been working with a small group of people on a coding project for

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.