I am trying to copy keypoints from one vector to another keypoint vector. I want to do this so that I can split the keypoints to thread them. The below is done by using all the keypoints found. (Copying is the problem, not the splitting, and these are done in the main thread, no threading here)
The values of keypoint1 and keypoint2 after copying are the same, but when I put them through the extracting descriptor and matching algorithm, keypoint1 and keypoint2 produces different results.
keypoint1 produces accurate results, whereas keypoint2 produces a lot of wrong results. I am using ORB algorithm
for detecting keypoints and descriptor extraction, and FlannBasedMatcher
for matching. I have tried a few methods to copy the keypoints, I tried push_back()
too, but its the same.
Method 1:
keypoint2.clear();
keypoint2.insert(keypoint2.begin(), keypoint1.begin(), keypoint1.end());
Method 2:
keypoint2.clear();
keypoint2.resize(keypoint1.size());
for (int i = 0; i < keypoint1.size(); ++i) {
keypoint2[i].pt.x = keypoint1[i].pt.x;
keypoint2[i].pt.y = keypoint1[i].pt.y;
keypoint2[i].size = keypoint1[i].size;
keypoint2[i].angle = keypoint1[i].angle;
keypoint2[i].response = keypoint1[i].response;
keypoint2[i].octave = keypoint1[i].octave;
keypoint2[i].class_id = keypoint1[i].class_id;
}
After copying the keypoints
extractor->compute(GrayImage2, keypoint2, descriptor_img2);
matcher.match(descriptor_img1, descriptor_img2, matches);
I can tell that its wrong because after this step, they go through the same filtering step to get better results. The differences in amount of correct data from using keypoint1 and keypoint2 are very large.
I tried using pointers to split the keypoint too, but I couldn't get the pointer to point at part of the keypoint vector.