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

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

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

IOUtils.read介绍

[英]Utility method to read any object written with #write(Object,DataOutput).
[中]读取用#write(对象,数据输出)写入的任何对象的实用方法。

代码示例

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

@Override
public void readBinary(DataInput in) throws IOException {
  final LazyFaceRecogniser<FACE, PERSON, EXTRACTOR> wrapper = IOUtils.read(in);
  this.extractor = wrapper.extractor;
  this.faceCache = wrapper.faceCache;
  this.internalRecogniser = wrapper.internalRecogniser;
  this.isInvalid = wrapper.isInvalid;
}

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

@SuppressWarnings("unchecked")
private FEATURE load(File cachedFeature) {
  try {
    return (FEATURE) IOUtils.read(cachedFeature);
  } catch (final Exception e) {
    try {
      return (FEATURE) IOUtils.readFromFile(cachedFeature);
    } catch (final IOException e1) {
      logger.warn("Error reading from cache. Feature will be regenerated.");
    }
  }
  return null;
}

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

@Override
public void readBinary(DataInput in) throws IOException {
  this.detector = IOUtils.read(in);
  this.groupingFilter = IOUtils.read(in);
  histogramEqualize = in.readBoolean();
}

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

@Override
public void readBinary(final DataInput in) throws IOException {
  super.readBinary(in);
  this.shape = IOUtils.read(in);
  this.poseParameters = IOUtils.read(in);
  this.shapeParameters = IOUtils.read(in);
}

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

@Override
public void readBinary(DataInput in) throws IOException {
  width = in.readInt();
  height = in.readInt();
  numComponents = in.readInt();
  pca = IOUtils.read(in);
}

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

@Override
public void readBinary(DataInput in) throws IOException {
  width = in.readInt();
  height = in.readInt();
  numComponents = in.readInt();
  pca = IOUtils.read(in);
}

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

@Override
public void readBinary(DataInput in) throws IOException {
  pq = IOUtils.read(in);
  ndims = in.readInt();
  int size = in.readInt();
  int dim = pq.assigners.length;
  data = new ArrayList<byte[]>(size);
  for (int i=0; i<size; i++) {
    byte[] bytes = new byte[dim];
    in.readFully(bytes);
    data.add(bytes);
  }
}

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

@Override
public void readBinary(DataInput in) throws IOException {
  pq = IOUtils.read(in);
  ndims = in.readInt();
  int size = in.readInt();
  int dim = pq.assigners.length;
  data = new ArrayList<byte[]>(size);
  for (int i=0; i<size; i++) {
    byte[] bytes = new byte[dim];
    in.readFully(bytes);
    data.add(bytes);
  }
}

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

@Override
public void readBinary(DataInput in) throws IOException {
  pq = IOUtils.read(in);
  ndims = in.readInt();
  int size = in.readInt();
  int dim = pq.assigners.length;
  data = new ArrayList<byte[]>(size);
  for (int i=0; i<size; i++) {
    byte[] bytes = new byte[dim];
    in.readFully(bytes);
    data.add(bytes);
  }
}

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

@Override
public void readBinary(DataInput in) throws IOException {
  config = IOUtils.read(in);
  loadReference();
}

代码示例来源:origin: org.openimaj.hadoop.tools/HadoopTwitterTokenTool

@Override
  public void map(final LongWritable key, BytesWritable value, final Mapper<LongWritable,BytesWritable,LongWritable,LongWritable>.Context context){
    try {
      final TweetCountWordMap periodCountWordCount = IOUtils.read(new ByteArrayInputStream(value.getBytes()), TweetCountWordMap.class);
      if(!key.equals(CountTweetsInTimeperiod.Map.END_TIME)){
        context.write(key, new LongWritable(periodCountWordCount.getNTweets()));
      }
      
    } catch (Exception e) {
      System.err.println("Couldnt read timeperiod: " + key);
    }
  }
}

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

@Override
  public void map(final LongWritable key, BytesWritable value, final Mapper<LongWritable,BytesWritable,LongWritable,LongWritable>.Context context){
    try {
      final TweetCountWordMap periodCountWordCount = IOUtils.read(new ByteArrayInputStream(value.getBytes()), TweetCountWordMap.class);
      if(!key.equals(CountTweetsInTimeperiod.Map.END_TIME)){
        context.write(key, new LongWritable(periodCountWordCount.getNTweets()));
      }
      
    } catch (Exception e) {
      System.err.println("Couldnt read timeperiod: " + key);
    }
  }
}

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

/**
 * Print info about clusters
 * 
 * @param options
 * @throws IOException
 */
public static void do_info(AbstractClusterQuantiserOptions options)
    throws IOException
{
  final SpatialClusters<?> cluster = IOUtils.read(new File(options.getTreeFile()), options.getClusterClass());
  System.out.println("Cluster loaded...");
  System.out.println(cluster);
}

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

public USMFStatus readStatus(String svalue) throws IOException {
  final USMFStatus status = IOUtils.read(new StringReader(svalue), new USMFStatus(GeneralJSONTwitter.class));
  // TwitterStatus status = TwitterStatus.fromString(svalue);
  if (status.isInvalid())
    throw new IOException("Invalid tweet");
  return status;
}

代码示例来源:origin: org.openimaj.hadoop.tools/HadoopTwitterTokenTool

public USMFStatus readStatus(String svalue) throws IOException {
  final USMFStatus status = IOUtils.read(new StringReader(svalue), new USMFStatus(GeneralJSONTwitter.class));
  // TwitterStatus status = TwitterStatus.fromString(svalue);
  if (status.isInvalid())
    throw new IOException("Invalid tweet");
  return status;
}

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

protected static synchronized void loadOptions(Mapper<Text, BytesWritable, NullWritable, Text>.Context context) throws IOException {
  if (finance == null) {
    Path financeLoc = new Path(context.getConfiguration().getStrings(CorrelateWordTimeSeries.FINANCE_DATA)[0]);
    FileSystem fs = HadoopToolsUtil.getFileSystem(financeLoc);
    finance = IOUtils.read(fs.open(financeLoc),YahooFinanceData.class);
    financeSeries = finance.seriesMapInerp(SINGLE_DAY);
    long[] times = financeSeries.get("High").getTimes();
    interp = new IntervalSummationProcessor<WordDFIDF[],WordDFIDF, WordDFIDFTimeSeries>(times);
  }
}

代码示例来源:origin: org.openimaj.hadoop.tools/HadoopTwitterTokenTool

protected static synchronized void loadOptions(Mapper<Text, BytesWritable, NullWritable, Text>.Context context) throws IOException {
  if (finance == null) {
    Path financeLoc = new Path(context.getConfiguration().getStrings(CorrelateWordTimeSeries.FINANCE_DATA)[0]);
    FileSystem fs = HadoopToolsUtil.getFileSystem(financeLoc);
    finance = IOUtils.read(fs.open(financeLoc),YahooFinanceData.class);
    financeSeries = finance.seriesMapInerp(SINGLE_DAY);
    long[] times = financeSeries.get("High").getTimes();
    interp = new IntervalSummationProcessor<WordDFIDF[],WordDFIDF, WordDFIDFTimeSeries>(times);
  }
}

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

public SimilarityMatrix getInput() throws IOException {
  SimilarityMatrix matrix = IOUtils.read(input, SimilarityMatrix.class);
  
  if (invertData)
    matrix = matrix.processInplace(new InvertData());
  
  return matrix;
}

代码示例来源:origin: org.openimaj.hadoop.tools/HadoopTwitterTokenTool

protected static synchronized void loadOptions(Reducer<Text,BytesWritable,NullWritable,Text>.Context context) throws IOException {
  if (finance == null) {
    Path financeLoc = new Path(context.getConfiguration().getStrings(CorrelateWordTimeSeries.FINANCE_DATA)[0]);
    FileSystem fs = HadoopToolsUtil.getFileSystem(financeLoc);
    finance = IOUtils.read(fs.open(financeLoc),YahooFinanceData.class);
    financeSeries = finance.seriesMapInerp(SINGLE_DAY);
    long[] times = financeSeries.get("High").getTimes();
    interp = new IntervalSummationProcessor<WordDFIDF[],WordDFIDF, WordDFIDFTimeSeries>(times);
  }
}

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

protected static synchronized void loadOptions(Reducer<Text,BytesWritable,NullWritable,Text>.Context context) throws IOException {
  if (finance == null) {
    Path financeLoc = new Path(context.getConfiguration().getStrings(CorrelateWordTimeSeries.FINANCE_DATA)[0]);
    FileSystem fs = HadoopToolsUtil.getFileSystem(financeLoc);
    finance = IOUtils.read(fs.open(financeLoc),YahooFinanceData.class);
    financeSeries = finance.seriesMapInerp(SINGLE_DAY);
    long[] times = financeSeries.get("High").getTimes();
    interp = new IntervalSummationProcessor<WordDFIDF[],WordDFIDF, WordDFIDFTimeSeries>(times);
  }
}

相关文章