hadoop缩放图像

7fyelxc5  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(280)

嗨,我正在尝试使用hipi和hadoop框架缩放图像。
public void map(hipiimageheader,floatimage image,context context)抛出ioexception,interruptedeexception{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看起来很复杂。。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题