androidopencvindexingflannbasedmatcher

passing index Parameters for Flann matcher using opencv on android


I'm trying to customize the Flann matcher in opencv by editing the index parameters, but I'm using java for android, and I don't know how exactly it works.
I found this answer but I don't know how to apply it in a correct way here is the code I've tried

    String yamlParam="%YAML:1.0\n"
            + "indexParams:\n"
            + "   -\n"
            + "      name: algorithm\n"
            + "      type: 23\n"
            + "      value: 1\n"
            + "   -\n"
            + "      name: trees\n"
            + "      type: 4\n"
            + "      value: 4\n";

    File outputF = File.createTempFile("FlannfDetectorParams", ".YAML", outputDir);
    writeToFile(outputF,yamlParam);
    descriptorMatcher.read(outputF.getPath());

and here's the error I'm getting

OpenCV Error: Assertion failed (sp.type() == FileNode::SEQ) in virtual void cv::FlannBasedMatcher::read(const cv::FileNode &)


Solution

  • You have to use the full format of the yml configuration file:

    %YAML:1.0
    ---
    format: 3
    indexParams:
       -
          name: algorithm
          type: 23
          value: 1
       -
          name: trees
          type: 4
          value: 4
    searchParams:
       -
          name: checks
          type: 4
          value: 32
       -
          name: eps
          type: 5
          value: 0.
       -
          name: sorted
          type: 15
          value: 1