MTK Android Based Phone IMEI Write Tool, DirecTV Now Launch Will Include Zero Rated Bandwidth on the Mobile Network, video entertainment product with a heavy mobile, Smartphone Apps Drive Content Usage, It will not surprise you that smartphones now are the ways most people interact with the Internet, Social Networking Web Server via Arbitrary Code Execution, Released Add New Method FOR Reset FRP Samsung

Friday, May 1, 2015

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

All New Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java - do you know that every day there are new gadgets that are created with new advantages to simplify your life, on the blog Gadget Center we will discuss about the latest gadgets and gadgets that have long ranging from speck and price, now we will discuss about All New Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java we have collected a lot of news to make this article to be really useful for you, please see.

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

You can also see our article on:


All New 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.



article titled All New Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java has been completed in the discussion

hopefully information about All New Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java can provide benefits for you in determining the gadget to suit your needs so much easier in living everyday life.

you just read the article entitled All New Convert IplImage to byte array or IplImage to Bitmap in JavaCV - Android Java if you feel this information is useful for you and want to bookmark it or want to share it please use link https://mjoaobrum.blogspot.com/2015/05/all-new-convert-iplimage-to-byte-array.html.

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

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

0 comments:

Post a Comment