org.openimaj.io.IOUtils.isBinary()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.openimaj.io.IOUtils.isBinary()方法的一些代码示例,展示了IOUtils.isBinary()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.isBinary()方法的具体详情如下:
包路径:org.openimaj.io.IOUtils
类名称:IOUtils
方法名:isBinary

IOUtils.isBinary介绍

[英]Extracts the binary header from object and calls the byte[] version
[中]从对象中提取二进制头并调用字节[]版本

代码示例

代码示例来源:origin: openimaj/openimaj

/**
 * Check whether a stream starts with a header. Uses isBinary (therefore
 * resetting the stream after the check)
 * 
 * @param bis
 *            the input stream
 * @param header
 *            the byte[] header
 * @return whether the stream starts with the header
 * @throws IOException
 *             error reading stream
 */
public static boolean readable(BufferedInputStream bis, byte[] header) throws IOException {
  return isBinary(bis, header);
}

代码示例来源:origin: openimaj/openimaj

/**
 * Check readability by checking whether a file starts with a given header.
 * Instantiate an input stream and check whether the stream isBinary (i.e.
 * starts with the header)
 * 
 * @see IOUtils#isBinary(BufferedInputStream, byte[])
 * 
 * @param f
 *            file to check
 * @param header
 *            the expected header
 * @return does the file start with the header
 * @throws IOException
 *             error reading file
 */
public static boolean readable(File f, byte[] header) throws IOException {
  FileInputStream fos = null;
  try {
    fos = new FileInputStream(f);
    final BufferedInputStream bis = new BufferedInputStream(fos);
    return isBinary(bis, header);
  } finally {
    try {
      if (fos != null)
        fos.close();
    } catch (final IOException e) {
    }
  }
}

代码示例来源:origin: openimaj/openimaj

/**
 * Extracts the binary header from object and calls the byte[] version
 * 
 * @see IOUtils#isBinary(BufferedInputStream,byte[])
 * 
 * @param <T>
 *            expected data type
 * @param bis
 *            stream containing data
 * @param obj
 *            instance of expected data type
 * @return does the stream contain binary information
 * @throws IOException
 *             problem reading input stream
 */
public static <T extends ReadableBinary> boolean isBinary(BufferedInputStream bis, T obj) throws IOException {
  return isBinary(bis, obj.binaryHeader());
}

代码示例来源:origin: openimaj/openimaj

bis = new BufferedInputStream(fis);
  return isBinary(bis, header);
} finally {
  if (fis != null)

代码示例来源:origin: openimaj/openimaj

@Override
public Header readHeader(InputStream bis) throws IOException {
  final BufferedInputStream bstream = new BufferedInputStream(bis);
  final boolean binary = IOUtils.isBinary(bstream, LocalFeatureList.BINARY_HEADER);
  if (binary)
    return BINARY_KEYPOINT.readHeader(bstream);
  else
    return LOWE_KEYPOINT_ASCII.readHeader(bstream);
}

代码示例来源:origin: openimaj/openimaj

@Override
public Header readHeader(InputStream bis) throws IOException {
  final BufferedInputStream bstream = new BufferedInputStream(bis);
  final boolean binary = IOUtils.isBinary(bstream, LocalFeatureList.BINARY_HEADER);
  if (binary)
    return ASIFTENRICHED_BINARY.readHeader(bstream);
  else
    return ASIFTENRICHED_ASCII.readHeader(bstream);
}

代码示例来源:origin: openimaj/openimaj

@Override
public FeatureFile read(InputStream stream) throws IOException {
  final BufferedInputStream bstream = new BufferedInputStream(stream);
  final boolean binary = IOUtils.isBinary(bstream, LocalFeatureList.BINARY_HEADER);
  if (binary)
    return ASIFTENRICHED_BINARY.read(bstream);
  else
    return ASIFTENRICHED_ASCII.read(bstream);
}

代码示例来源:origin: openimaj/openimaj

@Override
public FeatureFile read(InputStream stream) throws IOException {
  final BufferedInputStream bstream = new BufferedInputStream(stream);
  final boolean binary = IOUtils.isBinary(bstream, LocalFeatureList.BINARY_HEADER);
  if (binary)
    return BINARY_KEYPOINT.read(bstream);
  else
    return LOWE_KEYPOINT_ASCII.read(bstream);
}

代码示例来源:origin: openimaj/openimaj

if (obj instanceof ReadableBinary && isBinary(bis, ((ReadableBinary) obj).binaryHeader())) {
  final byte[] header = new byte[((ReadableBinary) obj).binaryHeader().length];
  bis.read(header, 0, header.length);

代码示例来源:origin: openimaj/openimaj

/**
 * Construct a new StreamLocalFeatureList from the given input stream.
 * 
 * @param <T>
 *            the type of local feature
 * @param stream
 *            the input stream
 * @param clz
 *            the class of local feature to read
 * @return a new list
 * @throws IOException
 *             if an error occurs reading from the stream
 */
public static <T extends LocalFeature<?, ?>> StreamLocalFeatureList<T> read(BufferedInputStream stream, Class<T> clz)
    throws IOException
{
  final boolean isBinary = IOUtils.isBinary(stream, LocalFeatureList.BINARY_HEADER);
  // read header
  final int[] header = LocalFeatureListUtils.readHeader(stream, isBinary, false);
  final int size = header[0];
  final int veclen = header[1];
  final int headerLength = header[2];
  final int recordLength = veclen + 4 * 4;
  return new StreamLocalFeatureList<T>(stream, size, isBinary, headerLength, recordLength, veclen, clz);
}

代码示例来源:origin: org.openimaj/core-feature

/**
 * Construct a new StreamLocalFeatureList from the given input stream.
 * 
 * @param <T>
 *            the type of local feature
 * @param stream
 *            the input stream
 * @param clz
 *            the class of local feature to read
 * @return a new list
 * @throws IOException
 *             if an error occurs reading from the stream
 */
public static <T extends LocalFeature<?, ?>> StreamLocalFeatureList<T> read(BufferedInputStream stream, Class<T> clz)
    throws IOException
{
  final boolean isBinary = IOUtils.isBinary(stream, LocalFeatureList.BINARY_HEADER);
  // read header
  final int[] header = LocalFeatureListUtils.readHeader(stream, isBinary, false);
  final int size = header[0];
  final int veclen = header[1];
  final int headerLength = header[2];
  final int recordLength = veclen + 4 * 4;
  return new StreamLocalFeatureList<T>(stream, size, isBinary, headerLength, recordLength, veclen, clz);
}

代码示例来源:origin: openimaj/openimaj

if (obj instanceof ReadableBinary && isBinary(bis, ((ReadableBinary) obj).binaryHeader())) {
  final byte[] header = new byte[((ReadableBinary) obj).binaryHeader().length];
  bis.read(header, 0, header.length);

代码示例来源:origin: openimaj/openimaj

throws IOException
final boolean isBinary = IOUtils.isBinary(keypointFile, LocalFeatureList.BINARY_HEADER);

代码示例来源:origin: org.openimaj/core-feature

throws IOException
final boolean isBinary = IOUtils.isBinary(keypointFile, LocalFeatureList.BINARY_HEADER);

代码示例来源:origin: openimaj/openimaj

/**
 * Create a MemoryLocalFeatureList by reading all the local features from
 * the specified file.
 * 
 * @param <T>
 *            the type of local feature
 * @param keypointFile
 *            the file from which to read the features
 * @param clz
 *            the class of local feature
 * @return a new MemoryLocalFeatureList populated with features from the
 *         file
 * @throws IOException
 *             if an error occurs reading the file
 */
public static <T extends LocalFeature<?, ?>> MemoryLocalFeatureList<T> read(File keypointFile, Class<T> clz)
    throws IOException
{
  final boolean isBinary = IOUtils.isBinary(keypointFile, LocalFeatureList.BINARY_HEADER);
  final MemoryLocalFeatureList<T> list = new MemoryLocalFeatureList<T>();
  if (isBinary) {
    LocalFeatureListUtils.readBinary(keypointFile, list, clz);
  } else {
    LocalFeatureListUtils.readASCII(keypointFile, list, clz);
  }
  return list;
}

代码示例来源:origin: org.openimaj/core-feature

/**
 * Create a MemoryLocalFeatureList by reading all the local features from
 * the specified file.
 * 
 * @param <T>
 *            the type of local feature
 * @param keypointFile
 *            the file from which to read the features
 * @param clz
 *            the class of local feature
 * @return a new MemoryLocalFeatureList populated with features from the
 *         file
 * @throws IOException
 *             if an error occurs reading the file
 */
public static <T extends LocalFeature<?, ?>> MemoryLocalFeatureList<T> read(File keypointFile, Class<T> clz)
    throws IOException
{
  final boolean isBinary = IOUtils.isBinary(keypointFile, LocalFeatureList.BINARY_HEADER);
  final MemoryLocalFeatureList<T> list = new MemoryLocalFeatureList<T>();
  if (isBinary) {
    LocalFeatureListUtils.readBinary(keypointFile, list, clz);
  } else {
    LocalFeatureListUtils.readASCII(keypointFile, list, clz);
  }
  return list;
}

代码示例来源:origin: org.openimaj/core-feature

/**
 * Create a MemoryLocalFeatureList by reading all the local features from
 * the specified stream.
 * 
 * @param <T>
 *            the type of local feature
 * @param stream
 *            the input stream from which to read the features
 * @param clz
 *            the class of local feature
 * @return a new MemoryLocalFeatureList populated with features from the
 *         file
 * @throws IOException
 *             if an error occurs reading the file
 */
public static <T extends LocalFeature<?, ?>> MemoryLocalFeatureList<T> read(BufferedInputStream stream, Class<T> clz)
    throws IOException
{
  final boolean isBinary = IOUtils.isBinary(stream, LocalFeatureList.BINARY_HEADER);
  final MemoryLocalFeatureList<T> list = new MemoryLocalFeatureList<T>();
  if (isBinary) {
    LocalFeatureListUtils.readBinary(stream, list, clz);
  } else {
    LocalFeatureListUtils.readASCII(stream, list, clz);
  }
  return list;
}

代码示例来源:origin: openimaj/openimaj

/**
 * Create a MemoryLocalFeatureList by reading all the local features from
 * the specified stream.
 * 
 * @param <T>
 *            the type of local feature
 * @param stream
 *            the input stream from which to read the features
 * @param clz
 *            the class of local feature
 * @return a new MemoryLocalFeatureList populated with features from the
 *         file
 * @throws IOException
 *             if an error occurs reading the file
 */
public static <T extends LocalFeature<?, ?>> MemoryLocalFeatureList<T> read(BufferedInputStream stream, Class<T> clz)
    throws IOException
{
  final boolean isBinary = IOUtils.isBinary(stream, LocalFeatureList.BINARY_HEADER);
  final MemoryLocalFeatureList<T> list = new MemoryLocalFeatureList<T>();
  if (isBinary) {
    LocalFeatureListUtils.readBinary(stream, list, clz);
  } else {
    LocalFeatureListUtils.readASCII(stream, list, clz);
  }
  return list;
}

相关文章