使用 OpenIMAJ 我想保存功能列表以供以后使用,但java.util.NoSuchElementException: No line found
在重新读取我刚刚保存的功能文件时出现异常(见下文)。我检查了文本文件是否存在,但我不确定完整内容是否应该是(它很长)。
有什么想法有什么问题吗?
提前致谢!
(我的试用代码粘贴在下面)。
java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Unknown Source)
at org.openimaj.image.feature.local.keypoints.Keypoint.readASCII(Keypoint.java:296)
at org.openimaj.feature.local.list.LocalFeatureListUtils.readASCII(LocalFeatureListUtils.java:170)
at org.openimaj.feature.local.list.LocalFeatureListUtils.readASCII(LocalFeatureListUtils.java:136)
at org.openimaj.feature.local.list.MemoryLocalFeatureList.read(MemoryLocalFeatureList.java:134)
...
我的试用代码如下所示:
Video<MBFImage> originalVideo = getVideo();
MBFImage frame = originalVideo.getCurrentFrame().clone();
DoGSIFTEngine engine = new DoGSIFTEngine();
LocalFeatureList<Keypoint> originalFeatureList = engine.findFeatures(frame.flatten());
try {
originalFeatureList.writeASCII(new PrintWriter(new File("featureList.txt")));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Saved feature list with "+originalFeatureList.size()+" keypoints.");
MemoryLocalFeatureList<Keypoint> loadedFeatureList = null;
try {
loadedFeatureList = MemoryLocalFeatureList.read(new File("featureList.txt"), Keypoint.class);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Loaded feature list with "+loadedFeatureList.size()+" keypoints.");