I'm trying to generate byte array from image for that i tried two different method but i'm not understanding which one is better because both method require so much time
so if any alternative available please suggest
Java code :
File newfile = new File(path);
BufferedImage originalImage = ImageIO.read(newfile);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(originalImage, "png", baos);
imageInByte = baos.toByteArray();
Opencv method which i tried :
Mat originalImage= Highgui.imread(path);
byte[] imageInByte = new byte[(int) (originalImage.total() * originalImage.channels())];
originalImage.get(0, 0, imageInByte);
System.out.println("CONVERTED TO BYTE");