This blog displays information about the latest android smartphone, price and specs as well as information applikaksi game that appeals to you, here are also a lot of software that you can download

Jumat, 01 Mei 2015

Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java

Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java - is looking for information, and in this blog Android Gadgets we have been providing very complete information from various sources that reliable, well we'll talk about the Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java as you need, please si read to completion.

Articles : Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java
full Link : Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java
Article android-java, Article featured, Article how-tos, Article programming,

You can also see our article on:


Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java

Hi techies,

Now iam gonna share a wonderful and efficient way on "How to convert IplImage to byte array in JavaCV" with pure java code.



How to convert IplImage to Android Bitmap

public static Bitmap IplImageToBitmap(IplImage src) {
Bitmap bm=null;
   int width = src.width();
   int height = src.height();
// Unfortunately cvCvtColor will not let us convert in place, so we need to create a new IplImage with matching dimensions.
IplImage frame2 = IplImage.create(width, height, opencv_core.IPL_DEPTH_8U, 4);
opencv_imgproc.cvCvtColor(src, frame2, opencv_imgproc.CV_BGR2RGBA);
                   // Now we make an Android Bitmap with matching size ... Nb. at this point we functionally have 3 buffers == image size. Watch your memory usage!
bm = Bitmap.createBitmap(frame2.width(), frame2.height(), Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(frame2.getByteBuffer());
//src.release();
frame2.release();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
return bm;
}


How to convert IplImage to byte[]

public static byte[] IplImageToByteArray(IplImage src) {
Bitmap bm=null;
    int width = src.width();
    int height = src.height();
 // Unfortunately cvCvtColor will not let us convert in place, so we need to create a new IplImage with matching dimensions.
  IplImage frame2 = IplImage.create(width, height, opencv_core.IPL_DEPTH_8U, 4);
  opencv_imgproc.cvCvtColor(src, frame2, opencv_imgproc.CV_BGR2RGBA);
                    // Now we make an Android Bitmap with matching size ... Nb. at this point we functionally have 3 buffers == image size. Watch your memory usage!
  bm = Bitmap.createBitmap(frame2.width(), frame2.height(), Bitmap.Config.ARGB_8888);
  bm.copyPixelsFromBuffer(frame2.getByteBuffer());
  //src.release();
  frame2.release();
  ByteArrayOutputStream stream = new ByteArrayOutputStream();
  bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
  return stream.toByteArray();
}

So hope you guys got this helper methods so useful for your JavaCV projects.
And don't forget to use the comment box below.



Articles Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java has been discussed

A few gadget information Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java, hopefully can provide benefits to you all.

You're reading an article Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java and this article url is https://androidtabletgadgets.blogspot.com/2015/05/convert-iplimage-to-byte-array-or.html you can bookmark , Hopefully this article could be useful and do not forget to always to this blog to find information on gadget.

Tag : , , , ,
Share on Facebook
Share on Twitter
Share on Google+

Related : Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java

0 komentar:

Posting Komentar