In my work I have to get image matrix from the encoded string of an image. I am using OpenCV and JAVA.
Can anyone tell me how to do this?
Code:
BufferedImage originalImage;
try {
originalImage = ImageIO.read(new File("D:\\testimg.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(originalImage, "jpeg", baos);
baos.flush();
imageInByte = baos.toByteArray();
baos.close();
String imageDataString = encodeImage(imageInByte);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception ex){
ex.printStackTrace();
}
Now I have the string of image. The imread() of opencv takes filepath as input param and create Mat, but I have to create the Mat from this imageDataString .
Thanks, Surodip