uvagfx / hipi

HIPI: Hadoop Image Processing Interface
http://hipi.cs.virginia.edu
BSD 3-Clause "New" or "Revised" License
133 stars 82 forks source link

How to write image(Mat) to .hib file? #21

Open isabek opened 8 years ago

isabek commented 8 years ago

Hi guys,

I have one question about Hipi.

In my program I want to write my image to .hib file. My code is below. In map method:

   public void map(HipiImageHeader key, FloatImage value, Context context)
            throws IOException, InterruptedException {

            Mat cvImage = this.convertFloatImageToOpenCVMat(value);
            Mat imageWithFaceDetections = this.countFaces(cvImage);

            BufferedImage bufferedImage = new BufferedImage(imageWithFaceDetections.width(), imageWithFaceDetections.height(), BufferedImage.TYPE_BYTE_GRAY);

            Configuration conf = new Configuration();
            HipiImageBundle hib = new HipiImageBundle(new Path(outHib), conf);
            hib.openForWrite(true);

            ByteArrayOutputStream os = new ByteArrayOutputStream();
            ImageIO.write(bufferedImage, "jpeg", os);
            InputStream is = new ByteArrayInputStream(os.toByteArray(), 0, os.size());
            hib.addImage(is, HipiImageHeader.HipiImageFormat.JPEG, key.getAllMetaData()); 
            hib.close();
            ......
    }

As a result: I get black image without anything. Any ideas?

qingmeizhujiu commented 8 years ago

have you solved it? I get the same problem. Please tell me your way . thx