Make IplImage from bytearray

599 views
Skip to first unread message

hardik pansuria

unread,
Nov 22, 2011, 2:02:04 AM11/22/11
to android-opencv
Hi all,

I dont know how to make IplImage image from bytearray...actually
from camera i am capturing frames and send to JNI through
jbytearray ,,but otherside i need to convert to IplImage ???


Can you help me??


Thanks

Roman

unread,
Nov 22, 2011, 4:22:36 AM11/22/11
to android-opencv
Hi,
IplImage is older native 1.x API new 2.x API use Mat instead. Download
2.3.1 build and look at samples folder.
http://opencv.willowgarage.com/wiki/AndroidSamples
This two does what you want:

Tutorial 2 Advanced - 1. Add Native OpenCV (can run on emulator) -
this example demonstrates how you can use OpenCV in your JNI code.

Tutorial 2 Advanced - 2. Mix Java + Native OpenCV (can run on
emulator) - shows how to use both C++ and Java API in a application.

Roman

Hardik

unread,
Nov 22, 2011, 4:48:35 AM11/22/11
to android...@googlegroups.com
Thanks so much Roman,

But i want to run motion detection example in android 2.2. Which uses IplImage (I think that code is pretty old )!!! so i dont know how to run this c code in android ?? can u guid me ?? or any sample is available ??


Thanks  again .
--
Regards,

Pansuria Hardik

Sourcebits  Inc.



Roman

unread,
Nov 22, 2011, 5:11:39 AM11/22/11
to android-opencv
IMHO, you can use samples anyway, but in native level (jni_part.cpp)
convert Mat to IplImage:
http://opencv.willowgarage.com/documentation/cpp/c++_cheatsheet.html
// Assuming somewhere IplImage *iplimg; exists
Mimg = iplimg; //Or just set the header of pre existing cv::Mat
//Ming to iplimg's data (no copying is done)
http://opencv.willowgarage.com/documentation/cpp/basic_structures.html
Backward conversion from
Mat to CvMat or IplImage is provided via cast operators
Mat::operator CvMat() const an Mat::operator IplImage() .
The operators do not copy the data.

But there must be better way - create IplImage directly from array but
my poor C++ knowledge dont know how:)

Roman

> *Pansuria Hardik
>
> Sourcebits  Inc.
> *

Hardik

unread,
Nov 22, 2011, 5:38:31 AM11/22/11
to android...@googlegroups.com
Thank you so much Roman ...let me try ...
Reply all
Reply to author
Forward
0 new messages