/** * Produce a {@link LocalFeatureList} of {@link FloatLocalFeatureAdaptor} by * wrapping the input list, and dynamically wrapping with the * {@link FloatLocalFeatureAdaptor}s on demand. * * @param list * the input list * @return the wrapped list */ public static <L extends Location> List<FloatLocalFeatureAdaptor<L>> wrap( final List<? extends LocalFeature<L, ?>> list) { return wrap(list, null); }
@Override public List<FloatLocalFeatureAdaptor<?>> apply(List<? extends LocalFeature<?, ?>> in) { return FloatLocalFeatureAdaptor.wrapUntyped(in, hell); } }
@SuppressWarnings("unchecked") @Override public FloatLocalFeatureAdaptor<?> get(int index) { return new FloatLocalFeatureAdaptor<Location>((LocalFeature<Location, ?>) list.get(index), normaliser); }
private FloatCentroidsResult cluster(List<FloatLocalFeatureAdaptor<?>> rawData) { // build full data array final float[][] vectors = new float[rawData.size()][]; for (int i = 0; i < vectors.length; i++) { vectors[i] = rawData.get(i).getFeatureVector().values; } // Perform clustering final FloatKMeans kmeans = FloatKMeans.createExact(numVladCentroids, numIterations); final FloatCentroidsResult centroids = kmeans.cluster(vectors); return centroids; } }
/** * Produce a {@link LocalFeatureList} of {@link FloatLocalFeatureAdaptor} by * wrapping the input list, and dynamically wrapping with the * {@link FloatLocalFeatureAdaptor}s on demand. * * @param list * the input list * @return the wrapped list */ public static <L extends Location> List<FloatLocalFeatureAdaptor<L>> wrap( final List<? extends LocalFeature<L, ?>> list) { return wrap(list, null); }
@Override public List<FloatLocalFeatureAdaptor<?>> apply(List<? extends LocalFeature<?, ?>> in) { return FloatLocalFeatureAdaptor.wrapUntyped(in); } },
@SuppressWarnings("unchecked") @Override public FloatLocalFeatureAdaptor<?> get(int index) { return new FloatLocalFeatureAdaptor<Location>((LocalFeature<Location, ?>) list.get(index), normaliser); }
/** * Load the raw features and create VLAD representations. * * @return * @throws IOException */ private static Map<Document, FloatFV> getVLADFeatures() throws IOException { final Map<Document, FloatFV> vladData = new HashMap<Document, FloatFV>(); final FloatCentroidsResult centroids = readFvecs(new File( "/Users/jsh2/Downloads/cvpr2010/data/clust_k64.fvecs")); final ExactFloatAssigner assigner = new ExactFloatAssigner(centroids); final VLAD<float[]> vlad = new VLAD<float[]>(assigner, centroids, true); for (final File f : new File("/Users/jsh2/Downloads/siftgeo/").listFiles()) { System.out.println("Loading " + f.getName()); final LocalFeatureList<SIFTGeoKeypoint> keys = SIFTGeoKeypoint.read(f); final List<FloatLocalFeatureAdaptor<SIFTGeoLocation>> fkeys = FloatLocalFeatureAdaptor.wrap(keys); final MultidimensionalFloatFV fv = vlad.aggregate(fkeys); vladData.put(new Document(f.getName()), fv); } return vladData; }
/** * Produce a {@link LocalFeatureList} of {@link FloatLocalFeatureAdaptor} by * wrapping the input list, and dynamically wrapping with the * {@link FloatLocalFeatureAdaptor}s on demand. * * @param list * the input list * @return the wrapped list */ public static List<FloatLocalFeatureAdaptor<?>> wrapUntyped( final List<? extends LocalFeature<?, ?>> list) { return wrapUntyped(list, null); }
@Override public FloatLocalFeatureAdaptor<L> get(int index) { return new FloatLocalFeatureAdaptor<L>(list.get(index), normaliser); }
/** * Load the raw features and create VLAD representations. * * @return * @throws IOException */ private static Map<Document, FloatFV> getVLADFeatures() throws IOException { final Map<Document, FloatFV> vladData = new HashMap<Document, FloatFV>(); final FloatCentroidsResult centroids = readFvecs(new File( "/Users/jsh2/Downloads/cvpr2010/data/clust_k64.fvecs")); final ExactFloatAssigner assigner = new ExactFloatAssigner(centroids); final VLAD<float[]> vlad = new VLAD<float[]>(assigner, centroids, true); for (final File f : new File("/Users/jsh2/Downloads/siftgeo/").listFiles()) { System.out.println("Loading " + f.getName()); final LocalFeatureList<SIFTGeoKeypoint> keys = SIFTGeoKeypoint.read(f); final List<FloatLocalFeatureAdaptor<SIFTGeoLocation>> fkeys = FloatLocalFeatureAdaptor.wrap(keys); final MultidimensionalFloatFV fv = vlad.aggregate(fkeys); vladData.put(new Document(f.getName()), fv); } return vladData; }
/** * Produce a {@link LocalFeatureList} of {@link FloatLocalFeatureAdaptor} by * wrapping the input list, and dynamically wrapping with the * {@link FloatLocalFeatureAdaptor}s on demand. * * @param list * the input list * @return the wrapped list */ public static List<FloatLocalFeatureAdaptor<?>> wrapUntyped( final List<? extends LocalFeature<?, ?>> list) { return wrapUntyped(list, null); }
@Override public FloatLocalFeatureAdaptor<L> get(int index) { return new FloatLocalFeatureAdaptor<L>(list.get(index), normaliser); }
final LocalFeatureList<SIFTGeoKeypoint> keys = SIFTGeoKeypoint.read(f); final List<FloatLocalFeatureAdaptor<SIFTGeoLocation>> fkeys = FloatLocalFeatureAdaptor.wrap(keys);
final LocalFeatureList<SIFTGeoKeypoint> keys = SIFTGeoKeypoint.read(f); final List<FloatLocalFeatureAdaptor<SIFTGeoLocation>> fkeys = FloatLocalFeatureAdaptor.wrap(keys);