Ask Your Question

awatson's profile - activity

2014-11-13 09:11:37 -0600 asked a question Keypoint params w/ OpenCV 3.0 + Java

I am able to detect keypoints in an image, using the default detector parameters. When I try to pass any parameters, using a YAML temp file, the application crashes. The call stack is not very helpful.

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    Mat mat = readImage("test.jpg", false);

    File f = new File("./");
    try {
        f = File.createTempFile("orbDetectorParams", ".YAML", new File("./data"));
        writeToFile(f, "%YAML:1.0\nnfeatures:600\n");
    } catch (IOException e) {
        e.printStackTrace();
    }

    FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
    // ****** UNCOMMENT THIS LINE, AND THE APPLICATION WILL CRASH...
    //detector.read(f.getPath());       

    MatOfKeyPoint keypoints = new MatOfKeyPoint();
    detector.detect(mat, keypoints);

    System.out.println (keypoints);

I have seen reference to crashes occurring when unexpected parameters are sent to the detector. Is my YAML file not correctly formatted?