How to convert from Iplimage to Mat in java?

asked 2014-09-29 12:18:54 -0500

updated 2014-09-30 08:38:32 -0500

berak gravatar image

Hi everyone,

I have trouble converting from Iplimage to Mat in java. Since OpenCV java API doesn't have ability to load video files, I utilized javacv to load video files. But then I need to convert Iplimage to Mat in order to use openCV to do face detection. What should I do to realize it?

Thanks for any help in advance!

Quan

edit retag flag offensive close merge delete

Comments

This might not be of much help (just bits and pieces)... but someone posted the structure of IplImage here:

http://stackoverflow.com/questions/17307430/explanation-of-iplimage-img

...and a fast function to convert Mat into java.awt.image.BufferedImage (which might resemble IplImage to some degree), can be found here:

http://answers.opencv.org/question/10344/opencv-java-load-image-to-gui/

( look for "public static BufferedImage matToBufferedImage(Mat bgr)" )

arp gravatar imagearp ( 2014-09-29 12:26:13 -0500 )edit

Basically, I would try to read the "imageData" field from IplImage structure and write it using "matrix.put(0, 0, data);" to the Mat object. If the dimensions and color palettes already match before trying this, it might succeed. But I've got no working method to try, since I can't get any IplImage structures on my system...

arp gravatar imagearp ( 2014-09-29 12:36:16 -0500 )edit