1

嗨,我正在尝试使用 HIPI 和 Hadoop 框架来缩放图像。

public void map(HipiImageHeader header, FloatImage image, Context context) throws IOException, InterruptedException { image.scale(20);

      if (header == null || image == null) {
       System.err.println("Failed to decode image, skipping.");
       return;
      }

      String source = header.getMetaData("source");
      if (source == null) {
       System.err.println("Failed to locate source metadata key/value pair, skipping.");
       return;
      }

      String base = FilenameUtils.getBaseName(source);
      if (base == null) {
        System.err.println("Failed to determine base name of source metadata value, skipping.");
        return;
      }

      Path outpath = new Path(path + "/" + base + ".jpg");

      FSDataOutputStream os = fileSystem.create(outpath);
      JpegCodec.getInstance().encodeImage(image, os);
      os.flush();
      os.close();

      context.write(new BooleanWritable(true), new Text(base));
    }
  }

我收到以下错误:

16/01/11 10:33:39 INFO mapreduce.Job: Task Id : attempt_1452491788150_0009_m_000000_1, Status : FAILED
Error: java.lang.ArrayIndexOutOfBoundsException: 2048
        at org.hipi.image.PixelArrayFloat.getElemNonLinSRGB(PixelArrayFloat.java:73)
        at org.hipi.image.io.ImageCodec.encodeRasterImage(ImageCodec.java:142)
        at org.hipi.image.io.JpegCodec.encodeImage(JpegCodec.java:124)
        at com.test.image$HelloWorldMapper.map(image.java:76)
        at com.test.image$HelloWorldMapper.map(image.java:1)
        at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

HIPI 看起来使用起来很复杂..

4

0 回答 0