计算非关键点的SURF / SIFT描述符

时间:2015-05-19 09:00:45

标签: opencv sift surf feature-extraction

实际上,我正在尝试将从图像中提取的关键点列表与从另一个图像中提取的另一个关键点列表进行匹配。我尝试使用SURF / SIFT来检测关键点,但结果并不像从每个图像检测到的关键点的准确性那样预期。我想不使用关键点检测器,只使用连接区域的点,然后使用SIFT / SUFT计算这些点的描述符,但大多数时候调用计算方法将清空关键点列表。

以下代码示例:

int minHessian = 100;
 SurfFeatureDetector detector(minHessian);  
Mat descriptors_object;
 SurfDescriptorExtractor extractor;
 detector.detect( img_object, keypoints_object); 
 extractor.compute( img_object, keypoints_object,descriptors_object ); 
 for (int index = 0; index < listOfObjectsExtracted.size(); index ++)
 {
         Mat partOfImageScene = listOfObjectsExtracted[index];
         vector<Point2f> listOfContourPoints = convertPointsToPoints2f(realContoursOfRects[index]);
         vector<KeyPoint> keypoints_scene;
         KeyPoint::convert(listOfContourPoints, keypoints_scene, 100, 1000);
         //detector.detect( partOfImageScene, keypoints_scene );
         if (keypoints_scene.size() > 0)
         {
             //-- Step 2: Calculate descriptors (feature vectors)
             Mat descriptors_scene;
             extractor.compute( partOfImageScene, keypoints_scene, descriptors_scene );
            //Logic of matching between descriptors_scene and descriptors_object 
         } 
}

因此,在步骤2中调用compute之后,keypoints_scene大多数时间都变为空。 我知道他们在OpenCV文档中声明了以下内容:

  

请注意,该方法可以通过删除关键点向量来修改   关键点,以便没有定义它们的描述符(通常   这些是图像边界附近的关键点)。该方法确保了   ouptut关键点和描述符彼此一致   (以便关键点的数量等于描述符行   计数)。

但无论如何要获得更好的结果?我的意思是对我选择的所有要点都有描述符?我是否违反了应该使用关键点的方式?我应该尝试使用与SIFT / SURF不同的特征提取器来获得我想要的吗?或者预计OpenCV中实现的每个功能检测器都会遇到同样的问题?

EDITED

我正在使用方法KeyPoint::convert将点转换为关键点,我将100作为大小传递,将1000作为响应传递。您可以在下面看到该方法的详细信息:

//! converts vector of points to the vector of keypoints, where each keypoint is assigned the same size and the same orientation
    static void convert(const vector<Point2f>& points2f,
                        CV_OUT vector<KeyPoint>& keypoints,
                        float size=1, float response=1, int octave=0, int class_id=-1);

作为尺码,100对我来说很好,不是吗?如果没有,任何方式来获得适合我的情况的最佳价值?或者只是凭经验?

EDITED : 图像的大小为1920 * 1080,这是sample

而且大多数时候他们都接近图像的边界。这有什么问题吗?

1 个答案:

答案 0 :(得分:1)

我明白了。问题在于我计算描述符的方式,因为正如您在上面的代码中所看到的,我试图在图像的一小部分而不是图像本身上计算描述符。因此,当我将图像本身而不是Scroller Knobs放置时,像partOfImageScene这样的东西就完美无缺,而且我没有从列表中丢失任何关键点。