Click here to Skip to main content
15,889,637 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to Convert from Byte Array to IplImage using JAVACV?



Java
protected void processImage(byte[] data, int width, int height) {
 	 int w = width, h = height;
         if (grayImage == null || grayImage.width() != w || grayImage.height() != h) {
        	 grayImage = IplImage.createHeader(new CvSize(width, height), IPL_DEPTH_8U, 3);
         }
         BytePointer rawImageData = new BytePointer(data);
         cvSetData(grayImage, rawImageData, w*3);
  String filename; filename =Environment.getExternalStorageDirectory().toString()+"/RGB-"+Math.random()+".jpg"; cvSaveImage(filename,grayImage); // Save a image for check .


But the code have problem with
Fatal signal 11 (SIGSEGV) at 0x5e2a2000 (code=1), thread 28133 (acv.facepreview)


Thanks all.
Posted

Hi everyone,

Here is the easiest way to convert IplImage to Byte Array or IplImage to Android Bitmap.

http://www.revealedtricks4u.com/2015/05/convert-iplimage-to-byte-array-or.html

Regards,
ShihabSoft
 
Share this answer
 
Here is the sample funtion, how to use do...

public static Image<bgr,> ConvertByteToImage(byte[] bytes)
{
return new Image<bgr,>(new Bitmap(Image.FromStream(new MemoryStream(bytes))));
}

this function made in visual studio 2010, and EmguCV 2.4.9.
It may be usefull to you, just change logic according to java.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900