Ask Your Question
1

Converting Mat to IplImage in Java

asked 2013-05-26 11:31:02 -0600

agile gravatar image

How can I convert Mat image to IplImage using Opencv4 android / javacv. I am using opencv for face detection but I need javacv for face recognition. and the face recognizer class require CvArr/IplImage as an input for the train method.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-08-18 12:37:50 -0600

agile gravatar image

updated 2013-08-18 12:39:25 -0600

I solved the problem by Converting Mat to Bitmap and then Bitmap to IplImage. There is a mehtod available in OpenCV for Android for coverting Mat to Bitmap and in JavaCV for converting Bitmap to IplImage.

edit flag offensive delete link more

Comments

Im having the same problem, can you post the code with yoir solution?

LopeLH gravatar imageLopeLH ( 2014-10-23 13:49:41 -0600 )edit
0

answered 2014-05-22 11:25:41 -0600

Axel gravatar image

Is there a way to convert Mat to IplImage for a java application? This solution you are giving only works in android (bitmap)?

edit flag offensive delete link more

Comments

it's probably wise to stick to one wrapper library here. opencv's and the javacv wrappers are basically incompatible(as javacv is mostly wrapping the deprecated c-api).

berak gravatar imageberak ( 2014-05-22 11:31:47 -0600 )edit

So you are pretty much saying that is not possible to cast mat to IplImage?

Axel gravatar imageAxel ( 2014-05-22 11:43:31 -0600 )edit

don't know javacv too well, but definitely not from opencv's java wrappers

berak gravatar imageberak ( 2014-05-22 11:48:23 -0600 )edit

I am developing an app in java where you can detect faces and record the footage at the same time. I need Mat in order to make the detection work, but if i want to record live footage from web cam I need to IplImage and that crashes the app unless I have two web cams running at the same time working separately.

Axel gravatar imageAxel ( 2014-05-22 11:55:38 -0600 )edit

aww, i see. so writing to video files is what got you into using javacv ?

(no real good idea here)

berak gravatar imageberak ( 2014-05-22 12:01:44 -0600 )edit

No. Object detection and Facial recognition got me into it, but I also wanted to record the footage.

Axel gravatar imageAxel ( 2014-05-22 12:08:23 -0600 )edit
1

k,k. i see. you could clearly do the object detection from plain opencv, but face reco would need additional jni.

btw, you can do :

 byte[] pixels; // from iplimage, if there's such a thing
 Mat m = new Mat(h,w,type); 
 m.put(0,0,pixels);

but i don't know the other direction (to IplImage)

berak gravatar imageberak ( 2014-05-22 12:14:32 -0600 )edit

Question Tools

Stats

Asked: 2013-05-26 11:31:02 -0600

Seen: 3,600 times

Last updated: May 22 '14