Samsung Galaxy Note, 4G LTE Plans, Transfer Photos Videos from iPhone to Samsung, Network Performance, Mobile Accounts, Furious Gold SPD TooL, Latest Version Full Setup

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

Info Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java - this blog we have built from a few years ago and already very much information about gadgets that we convey and a lot of blog visitors New Blog Techno News who are satisfied with the information, we will always try to update the latest information for you, first about Info Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java many already we collect data to make this article so you do not miss the news, please see:

Articles : Info Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java
full Link : Info Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java

You can also see our article on:


Info 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 Info Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java finished in discussion

hopefully the information we convey about Info Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java can benefit you in getting new knowledge about technology,

you just finished reading the information Info Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java we hope this informmation can answer the question you submit to googlle, if you want to bookmark or share please use link https://moymoycikukecik.blogspot.com/2015/05/info-convert-iplimage-to-byte-array-or.html and do not forget to always visit this blog to get the latest information every day.

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

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

0 komentar:

Posting Komentar