1 | initial version |
If you don't have the OpenCVTestRunner, this does the job (Exception-Handling omitted):
private void init() {
[...]
FeatureDetector orbDetector = FeatureDetector.create(FeatureDetector.ORB);
File outputDir = getCacheDir(); // If in an Activity (otherwise getActivity.getCacheDir();
File outputFile = File.createTempFile("orbDetectorParams", ".YAML", outputDir);
writeToFile(outputFile, "%YAML:1.0\nscaleFactor: 1.2\nnLevels: 8\nfirstLevel: 0 \nedgeThreshold: 31\npatchSize: 31\nWTA_K: 2\nscoreType: 1\nnFeatures: 500\n");
orbDetector.read(outputFile.getPath());
[... use detector ... ]
}
private void writeToFile(File file, String data) {
FileOutputStream stream = new FileOutputStream(file);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(stream);
outputStreamWriter.write(data);
outputStreamWriter.close();
stream.close();
}