我正在使用Java,OpenCV和Maven开展图像识别项目。不幸的是,我看到以下错误:
“java.io.IOException:无法运行程序”akaze / bin / akaze_match“:CreateProcess error = 2,系统找不到指定的文件
引起:java.io.IOException:CreateProcess error = 2,系统找不到指定的文件“
程序在指定的目标中创建.json文件;但.json文件总是空的。
相关代码是:
private String runAkazeMatch(String object_filename, String scene_filename) throws InterruptedException, IOException {
long timestamp = System.currentTimeMillis();
String jsonFilename = "target/keypoints/keypoints_" + timestamp + ".json";
logger.info("Json file should be found at: {}", jsonFilename);
File file = new File(jsonFilename);
file.getParentFile().mkdirs();
file.createNewFile();
System.out.println(file.getParentFile().mkdirs());
String[] akazeMatchCommand = {"akaze/bin/akaze_match", object_filename, scene_filename, "--json", jsonFilename, "--dthreshold", "0.00000000001"};
try {
ProcessBuilder p = new ProcessBuilder(akazeMatchCommand);
Process proc = p.start();
InputStream stdin = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null)
System.out.print(".");
int exitVal = proc.waitFor();
logger.info("Akaze matching process exited with value: " + exitVal);
} catch (Throwable t) {
t.printStackTrace();
}
if (!file.exists()) {
logger.error("ERROR: Image recognition with Akaze failed. No json file created.");
return null;
} else {
return jsonFilename;
}
}
我搜索过这个问题;我猜这是关于Java的AKAZE。 可能是什么问题呢?我应该如何在Java上使用AKAZE?
提前谢谢。