java - OpenImaj 库中 BagOfVisualWord 类的使用

标签 java generics openimaj

所以在我的例子中,我应该向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/

相关文章:

java - OpenIMAJ 无法访问视频文件

java - 除了测试,为什么我们需要 Dagger 2?

C# - 获取通用列表的项目类型

delphi - Delphi 中的泛型会导致性能瓶颈吗?

java - 多个摄像头同时openimaj

Java代码打开应用程序并显示图标

java - 自定义 CellRenderer 已调用但似乎没有效果

java - 如何在IDEA中打开jmeter项目?

java - JPA:如何处理多个实体

C++ 查找包含类型