所以在我的例子中,我应该向computeQuantizedFeatures方法提供两个参数,第二个参数的类型为
List<LocalFeature<Location, ? extends ArrayFeatureVector<byte[]>>>
我尝试传递我的 imagekeypoints 类型列表
LocalFeatureList<Keypoint>
还有
List<LocalFeature<KeypointLocation, ByteFV>> features = null;
for (java.util.Iterator<Keypoint> iter = imageKeypoints.iterator(); iter.hasNext();)
{features.add((LocalFeature<KeypointLocation, ByteFV>)iter.next());}
但我总是遇到著名的错误
The method computeQuantisedFeatures(HardAssigner<T,?,?>, List<LocalFeature<L,?
extends ArrayFeatureVector<T>>>) in the type BagOfVisualWords is not applicable for
the arguments (HardAssigner<byte[],capture#3-of ?,capture#4-of ?>,
List<LocalFeature<KeypointLocation,ByteFV>>)
最佳答案
注意:我的答案基于 Keypoint
来源here .
这个问题是由于泛型 aren't covariant 。该方法需要 List<LocalFeature<L, ? extends ArrayFeatureVector<T>>>
,但您提供的是 List<Keypoint>
。如果该方法采用 List<? extends LocalFeature<L, ? extends ArrayFeatureVector<T>>>
相反,这将是一个合法的调用。
最简单的解决方案是复制 imagekeypoints
的内容进入新创建的List<LocalFeature<KeypointLocation, ByteFV>>
并将其传递到调用中。
关于java - OpenImaj 库中 BagOfVisualWord 类的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15342502/