How to write image(Mat) to .hib file?
Opened this issue · 1 comments
isabek commented
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
have you solved it? I get the same problem. Please tell me your way . thx