@Override protected F convert(T ele) { return ele.getFeatureVector().values; } }
/** * Utility method to construct a list of quantised local features (local * features with visual word assignments) from a list of features and a * {@link HardAssigner}. * * @param assigner * the assigner to apply to the feature vectors to create the * visual word identifiers * @param features * the features to process * @return a list of features with visual word assignments */ 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; }
protected static <T extends LocalFeature<?, ?>> void writeASCII(PrintWriter out, LocalFeatureList<T> list) throws IOException { final Locale def = Locale.getDefault(); Locale.setDefault(Locale.ENGLISH); out.println(list.size() + " " + list.vecLength()); for (final T k : list) k.writeASCII(out); Locale.setDefault(def); }
@Override public L getLocation() { return localFeature.getLocation(); }
protected static <T extends LocalFeature<?, ?>> void writeBinary(DataOutput out, LocalFeatureList<T> list) throws IOException { out.writeInt(list.size()); out.writeInt(list.vecLength()); for (final T k : list) k.writeBinary(out); }
protected static <T extends LocalFeature<?, ?>> void readBinary(DataInput in, MemoryLocalFeatureList<T> memoryKeypointList, Class<T> clz) throws IOException { final int nItems = in.readInt(); final int veclen = in.readInt(); memoryKeypointList.clear(); memoryKeypointList.cached_veclen = veclen; for (int i = 0; i < nItems; i++) { final T t = newInstance(clz, veclen); t.readBinary(in); memoryKeypointList.add(t); } }
protected static <T extends LocalFeature<?, ?>> void readASCII(BufferedInputStream bis, MemoryLocalFeatureList<T> memoryKeypointList, Class<T> clz) throws IOException { final Scanner in = new Scanner(bis); // read the header line final String head = in.nextLine().trim(); final String[] h = head.split(" "); final int nItems = Integer.decode(h[0]); int veclen = 0; if (h.length > 1) { veclen = Integer.decode(h[1]); } else { veclen = Integer.decode(in.nextLine().trim()); } memoryKeypointList.clear(); memoryKeypointList.cached_veclen = veclen; for (int i = 0; i < nItems; i++) { final T t = newInstance(clz, veclen); t.readASCII(in); memoryKeypointList.add(t); } }
@Override public L getLocation() { return localFeature.getLocation(); }
protected static <T extends LocalFeature<?, ?>> void writeBinary(DataOutput out, LocalFeatureList<T> list) throws IOException { out.writeInt(list.size()); out.writeInt(list.vecLength()); for (final T k : list) k.writeBinary(out); }
protected static <T extends LocalFeature<?, ?>> void readBinary(DataInput in, MemoryLocalFeatureList<T> memoryKeypointList, Class<T> clz) throws IOException { final int nItems = in.readInt(); final int veclen = in.readInt(); memoryKeypointList.clear(); memoryKeypointList.cached_veclen = veclen; for (int i = 0; i < nItems; i++) { final T t = newInstance(clz, veclen); t.readBinary(in); memoryKeypointList.add(t); } }
protected static <T extends LocalFeature<?, ?>> void readASCII(BufferedInputStream bis, MemoryLocalFeatureList<T> memoryKeypointList, Class<T> clz) throws IOException { final Scanner in = new Scanner(bis); // read the header line final String head = in.nextLine().trim(); final String[] h = head.split(" "); final int nItems = Integer.decode(h[0]); int veclen = 0; if (h.length > 1) { veclen = Integer.decode(h[1]); } else { veclen = Integer.decode(in.nextLine().trim()); } memoryKeypointList.clear(); memoryKeypointList.cached_veclen = veclen; for (int i = 0; i < nItems; i++) { final T t = newInstance(clz, veclen); t.readASCII(in); memoryKeypointList.add(t); } }
@Override protected F convert(T ele) { return ele.getFeatureVector().values; } }
/** * Utility method to construct a list of quantised local features (local * features with visual word assignments) from a list of features and a * {@link HardAssigner}. * * @param assigner * the assigner to apply to the feature vectors to create the * visual word identifiers * @param features * the features to process * @return a list of features with visual word assignments */ 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; }
final SpatialLocation l = f.getLocation();
instance.writeBinary(new DataOutputStream(buffer));
protected static <T extends LocalFeature<?, ?>> void readBinary(BufferedInputStream bis, MemoryLocalFeatureList<T> memoryKeypointList, Class<T> clz) throws IOException { DataInputStream dis = null; dis = new DataInputStream(bis); // read the header line dis.read(new byte[memoryKeypointList.binaryHeader().length]); final int nItems = dis.readInt(); final int veclen = dis.readInt(); memoryKeypointList.clear(); memoryKeypointList.cached_veclen = veclen; for (int i = 0; i < nItems; i++) { final T t = newInstance(clz, veclen); t.readBinary(dis); memoryKeypointList.add(t); } }
protected static <T extends LocalFeature<?, ?>> void writeASCII(PrintWriter out, LocalFeatureList<T> list) throws IOException { final Locale def = Locale.getDefault(); Locale.setDefault(Locale.ENGLISH); out.println(list.size() + " " + list.vecLength()); for (final T k : list) k.writeASCII(out); Locale.setDefault(def); }
@Override public boolean test(LocalFeature<?, ByteFV> object) { return entropy(object.getFeatureVector().values) >= threshold; }
final SpatialLocation l = f.getLocation();
instance.writeBinary(new DataOutputStream(buffer));