JavaCV passing Java arrays to functions with @StdVector

369 views Asked by At

I'm trying to call JavaCV's groupRectangles function. Here is the method signature

@Namespace("cv") public static native void groupRectangles(@StdVector("CvRect,cv::Rect") CvRect rectList,
        @StdVector IntPointer weights, int groupThreshold, double eps/*=0.2*/);

From the OpenCV documentation, parameters one and two should be std::vector<>'s. I would assume I should pass in some form of Java array (native array, List, etc.), however, the method only has an annotation for a @StdVector, and accepts just a single object.

Can someone please provide a very small snippet of code showing how to properly call this method by passing in two Java lists or arrays or whatever.

1

There are 1 answers

0
Jon On

I have found the answer through the mailing list here. The only modification I made is below:

final CvRect rectsPointer = new CvRect(faces.size());
for (int i=0; i<faces.size(); ++i)
    rectsPointer.position(i).put(faces.get(i));