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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:38:14+00:00 2026-05-22T16:38:14+00:00

I wrote a c++ application that compares points matches from images (OpenSurf C++) but

  • 0

I wrote a c++ application that compares points matches from images (OpenSurf C++) but some times, 1 from some thousands of “getUniqueMatches”, the application breaks in some point inside “getUniqueMatches”. I has this log:

05/13/11 10:17:16: this->pointsA = 227
05/13/11 10:17:16: this->pointsB = 226
05/13/11 10:17:16: this->matches before = 0
05/13/11 10:17:16: 227 226 0 0.650000
05/13/11 10:17:16: Starting in getUniqueMatches

-- And here breaks, inside getUniqueMatches --

And this is the code:

inline bool findInVector(std::vector<int> v, int value) {
    int size = v.size();
    for(int i=0; i<size; i++) {
        if(v[i] == value) {
            return true;
        }
    }

    return false;
}

void getUniqueMatches(IpVec &ipts1, IpVec &ipts2, IpPairVec &matches, float ratio) {
    try {
        wLog(f("%d %d %d %f", ipts1.size(), ipts2.size(), matches.size(), ratio));

        float dist, d1, d2;
        Ipoint *match;

        matches.clear();

        std::vector<int> matched;

        wLog("Starting in getUniqueMatches");

        // Breaks after here

        int size = ipts1.size();
        int size2 =  ipts2.size();

        for (int i = 0; i < size; i++) {
            d1 = d2 = FLT_MAX;

            int foundJ = -1;

            for (unsigned int j = 0; j < size2; j++) {
                dist = ipts1[i] - ipts2[j];

                if (dist < d1 && !findInVector(matched, j)) {
                    d2 = d1;
                    d1 = dist;
                    match = &ipts2[j];
                    foundJ = j;
                } else if (dist < d2) {
                    d2 = dist;
                }
            }

            if (d1 / d2 < ratio) {
                ipts1[i].dx = match->x - ipts1[i].x;
                ipts1[i].dy = match->y - ipts1[i].y;

                matches.push_back(std::make_pair(ipts1[i], *match));
                matched.push_back(foundJ);
            }
        }
    } catch(std::exception ex) {
        wLog(f("Exception in getUniqueMatches: ", ex.what()));
        return;
    }
}

Only some times breaks here. I don’t know what is happening, maybe something wrong? The application uses only 1 thread when executing this function. When extracting points uses 10 threads.

Using it on Centos5 (VPS).
2 Gb RAm
20% hd used
Compiled using g++ (Performance mode), IDE used Netbeans.
OpenCV, libcurl.

  • 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-22T16:38:15+00:00Added an answer on May 22, 2026 at 4:38 pm

    I suspect 2 things:

    • g++ compiler optimization. Use -O2 or less; -O3 and beyond sometimes generate weird behavior especially concerning floating point operation.

    • If reducing optimization does not fix the problem, I suggest changing

      if (d1 / d2 < ratio)

      to

      if (d1 < double(ratio)*d2)

      for avoiding division by zero (unlikely happen I think) and for better precision result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Forms application that I wrote that does some monitoring of
I wrote an application that currently runs against a local instance of MySql. I
I wrote an application that loops through a set of records and prints two
I have wrote an application that syncs two folders together. The problem with the
I wrote a C# application that is a simple countdown timer. I use it
I have got a Wavecom Supreme GSM modem. I wrote a simple application that
I wrote a small PHP application that I'd like to distribute. I'm looking for
I've got an application that just shipped. Since I wrote it, I've learned about
I have a process that currently runs in a Delphi application that I wrote
I wrote myself a little downloading application so that I could easily grab a

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.