我在计算SIFT检测器发现的关键点的ORB描述符时遇到很大的问题。如果我尝试运行一个简单的示例程序,则整个系统将死机,我无法弄清原因。示例代码如下:

import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImageM;

import com.googlecode.javacv.cpp.opencv_core.CvMat;
import com.googlecode.javacv.cpp.opencv_features2d.DescriptorExtractor;
import com.googlecode.javacv.cpp.opencv_features2d.FeatureDetector;
import com.googlecode.javacv.cpp.opencv_features2d.KeyPoint;
import com.googlecode.javacv.cpp.opencv_features2d.ORB;
import com.googlecode.javacv.cpp.opencv_nonfree.SIFT;

public class DescriptorTest {

    public static void main(String[] args) {
        SIFT sift = new SIFT(0, 3, 0.04, 10, 1.6);
        FeatureDetector detector = sift.getFeatureDetector();
        ORB orb_descriptor = new ORB(500, 1.2f, 8, 31, 0, 2, 0, 31);
        DescriptorExtractor descriptor = orb_descriptor.getDescriptorExtractor();
        CvMat image = cvLoadImageM("res/dvd_009_ref.jpg");
        KeyPoint keypoints = new KeyPoint();
        CvMat descriptors = new CvMat(null);
        detector.detect(image, keypoints, null);
        System.out.println("Keypoints found: "+ keypoints.capacity());
        descriptor.compute(image, keypoints, descriptors);
        System.out.println("Descriptors calculated: "+descriptors.rows());
    }
}

有谁知道这是什么问题?会很好 :)

最佳答案

好的,因此,如果将关键点的 Octave 设置为0似乎可行。我尚不知道这是否是一个好主意,但我倾向于拒绝。因为对于某些描述符,在其中找到特征的比例空间 Octave 音阶的信息至关重要。

for(int i = 0; i < keypoints.capacity(); i++) {
    KeyPoint kp = keypoints.position(i);
    kp.octave(0);
}
keypoints.position(0);

关于opencv - JavaCV计算SIFT关键点的ORB描述符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11634551/

10-12 22:20