1

So in my case i should provide to computeQuantisedFeatures method two arguments , the second one is of type

        List<LocalFeature<Location, ? extends ArrayFeatureVector<byte[]>>>

i try to pass my imagekeypoints list which is of type

    LocalFeatureList<Keypoint>

and also

    List<LocalFeature<KeypointLocation, ByteFV>> features = null;
    for (java.util.Iterator<Keypoint> iter = imageKeypoints.iterator(); iter.hasNext();)
    {features.add((LocalFeature<KeypointLocation, ByteFV>)iter.next());}

but i always get the famous error

    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>>)
nawara
  • 1,157
  • 3
  • 24
  • 49

2 Answers2

1

Note: I based this answer on the Keypoint source here.

This problem arises from the fact that generics aren't covariant. The method expects a List<LocalFeature<L, ? extends ArrayFeatureVector<T>>>, but you're providing a List<Keypoint>. If the method took a List<? extends LocalFeature<L, ? extends ArrayFeatureVector<T>>> instead, it would be a legal call.

The simplest solution is to copy the contents of imagekeypoints into a newly created List<LocalFeature<KeypointLocation, ByteFV>> and pass that into the call instead.

Paul Bellora
  • 54,340
  • 18
  • 130
  • 181
  • i try this but i still get same error ` List> imagekeypointsList = new ArrayList>(); for (Keypoint key :imageKeypoints) {imagekeypointsList.add(key);}` Not that hardassigner also is not applicable – nawara Mar 12 '13 at 09:08
  • Hmm, that should work. Did you try Jon's solution? Please update the question with your latest code and error if it still isn't working. – Paul Bellora Mar 12 '13 at 13:28
  • thanks paul yes i try it problem is solved for assigner but not for features i will update my question – nawara Mar 12 '13 at 15:52
  • Hmm, I think you're missing something basic here. According to the error you're still passing in the same `List>`. – Paul Bellora Mar 12 '13 at 16:15
  • yes , may be keypoints aren't the right choise i hope Dr jon give me a suggestion – nawara Mar 12 '13 at 16:21
1

As noted by Paul Bellora, this is actually a bug in the generics of that method. I've just committed a fix which will be available in the 1.1.1-SNAPSHOT versions shortly. A temporary solution is to implement the correct version of the computeQuantisedFeatures method in your class as follows:

public static <L extends Location, T> List<QuantisedLocalFeature<L>> computeQuantisedFeatures(
    HardAssigner<T, ?, ?> assigner,
    List<? extends LocalFeature<L, ? extends ArrayFeatureVector<T>>> features)
{
    final List<QuantisedLocalFeature<L>> out = new ArrayList<QuantisedLocalFeature<L>>(features.size());

    for (final LocalFeature<L, ? extends ArrayFeatureVector<T>> f : features) {
        final int idx = assigner.assign(f.getFeatureVector().values);
        out.add(new QuantisedLocalFeature<L>(f.getLocation(), idx));
    }

    return out;
}
Jon
  • 841
  • 4
  • 5