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

  • Home
  • SEARCH
  • 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 8894611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:32:40+00:00 2026-06-14T23:32:40+00:00

I am stuck with a problem to have this loop of iterators work on

  • 0

I am stuck with a problem to have this loop of iterators work on CUDA.
can anyone help here ?

std::vector<cv::DMatch>  matches;
std::vector<cv::KeyPoint> key_pts1, key_pts2;
std::vector<cv::Point2f> points1, points2;
for (std::vector<cv::DMatch>::const_iterator itr = matches.begin(); itr!= matches.end(); ++it) 
        {                   
            float x = key_pts1[itr->queryIdx].pt.x;
            float y = key_pts1[itr->queryIdx].pt.y;
            points1.push_back(cv::Point2f(x,y));                
            x = key_pts2[itr->trainIdx].pt.x;
            y = key_pts2[itr->trainIdx].pt.y;
            points2.push_back(cv::Point2f(x,y));            
        }

This above conversion to CUDA – parallel processing, as I have thought seems quite difficult to me.

void dmatchLoopHomography(float *itr, float *match_being, float *match_end, float      *keypoint_1, float *keypoint_2, float *pts1, float *pts2)
{
float x, y;
// allocate memory in GPU memory
unsigned char *mtch_begin, *mtch_end, *keypt_1, *keypt_2, points1, *points2; 
cudaHostGetDevicePointer(&mtch_begin, match_being, 0);
cudaHostGetDevicePointer(&mtch_end, match_end, 0);
cudaHostGetDevicePointer(&keypt_1, keypoint_1, 0);
cudaHostGetDevicePointer(&keypt_2, keypoint_2, 0);
cudaHostGetDevicePointer(&points1, pts1, 0);
cudaHostGetDevicePointer(&points2, pts2, 0);

//dim3 blocks(16, 16); 
dim3 threads(itr, itr); 
//kernal
dmatchLoopHomography_ker<<<itr,itr>>>(mtch_begin, mtch_end, keypt_1, keypt_2, points1. points2)
cudaThreadSynchronize();    
}

and

 __global__ void dmatchLoopHomography_ker(float *itr, float *match_being, float *match_end, float *keypoint_1, float *keypoint_2, float *pts1, float *pts2)
{
 //how do I go about it ??
}
  • 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-06-14T23:32:41+00:00Added an answer on June 14, 2026 at 11:32 pm

    First, I noticed that your program consists of moving a vector<KeyPoint> into a vector<Point2f> structure. OpenCV has a really nice one-liner to do this for you:

    using namespace cv;
    KeyPoint::convert(key_pts1, points1); //vector<KeyPoint> to vector<Point2f>
    

    Now, let’s talk GPU stuff. It turns out that cudaHostGetDevicePointer() doesn’t allocate memory. You’ll want cudaMalloc() for allocating memory. For example:

    //compile with nvcc, not gcc
    float* device_matches;
    int match_length = matches.end() - matches.begin();
    cudaMalloc(&device_matches, match_length*sizeof(float));
    //do the same as above for key_pts1, key_pts2, points1, and points2
    

    Now, device_matches is just a plain C array, not an STL vector. So, you don’t have iterators. Instead, you have to just use ordinary array indices. If you really want iterators on the GPU, look at the Thrust library. Thrust is really handy, but the downside is that Thrust only provides a specific set of pre-baked functions.


    The bigger question is whether you want to do this particular part of your program on the GPU. I’d recommend using the GPU for really compute-intensive stuff (for example, the actual feature matching), but moving data between data formats (as in your example code) is many orders of magnitude cheaper than feature matching.

    Also, bear in mind that you often have to structure your data differently on the GPU than you would on the CPU. This restructuring isn’t necessarily computationally expensive, but you’ll want to set aside some time to work it out on the whiteboard, tear your hair out, etc. Finally, if you’re serious about GPU stuff, it might be worth working through a few simple GPU programming examples (I’ve enjoyed the Dr. Dobbs Supercomputing for the Masses tutorials), taking a GPU/parallel class, or talking to some GPU-hacker friends.

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

Sidebar

Related Questions

I am stuck at a small problem. I have this button within a form
Hope to get solution to this problem. I have been stuck on it since
i've been stuck in this loop for a while. Basically i have a slider
I hoping someone can help me with a problem I'm stuck(again) with. if i
I'm stuck with a problem of the python wrapper for OpenCv. I have this
I've been stuck with this problem from a couple of days and I can't
I have been stuck on this problem for many hours, but I have a
I have this problem, see the trace stack: E/AndroidRuntime(2410): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML
I'm new to wicket and stuck with the following problem: I have a table
I am stuck on a problem: in my software I have to code 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.