Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a java collection of images to CvArr

I want to use OpenCV's FaceRecognition in java through javacv wrapper library. I don't know how to pass images and labels to com.googlecode.javacv.cpp.opencv_contrib.FaceRecognizer.train(CvArr, CvArr)

I can use cvLoadImage(String) or cvLoadImageM(String) to obtain single images, but how do I make an CvArr of them?

like image 281
milan Avatar asked Nov 13 '22 02:11

milan


1 Answers

After some reading I found out that CvArr is an opaque type. You just initialize with any data - it is just a C pointer after all. So:

CvMat[] images = new CvMat[n];
images[0] = cvLoadImageM(...);
...
CvArr arr = new CvArr(new CvMatArray(images));
like image 157
milan Avatar answered Nov 30 '22 23:11

milan