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); } }
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 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); } }