문제

Can any one please tell me how to make descriptor's are of fix size ? because we may get different number of descriptors from different images For example If i have image of 450*550 and i am apply surf feature on it , than surf extract keypoints from it and than it extract descriptors from it , for example ,It extract 10 descriptors of keypoints from 450*550 image , than it read again an image and its size it 750*880 , so surf extract keypoints from it and than descriptors , for example this time it extract 20 descriptors from this image , Now What i want to do is , i want that whatever the size of image , the size size of descriptors should be same , like it should take 10 descriptors from both images, so in case of many images it should select the minimum size of descriptor and extract only that descriptors from all images and leave others , Or i define the size and it ignore the images who descriptors are below or above that size

extractor.compute( tmplate_img, keypoints, descriptors);
my_img=descriptors.reshape(1,1);

I want to make the same size of descriptors for all the images when i run it through loop and which size of descriptor is better for getting better result , descriptors is MAT.

Thanks

도움이 되었습니까?

해결책

You can use the following code to keep the top M keypoints that have the largest response:

bool compareFunction(KeyPoint p1, KeyPoint p2) {return p1.response>p2.response;}
//The function retains the stongest M keypoints in kp
void RetainBestKeypoints(vector<KeyPoint>  &kp, int M)
{
    vector<KeyPoint>  sortedkp;

    sort(kp.begin(),kp.end(),compareFunction);
    if (kp.size()>M)
            kp.erase(kp.begin()+M,kp.end());
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top