For the point, I recommend just passing x and y as doubles. For MatOfPoints and others:
OpenCV , Mat.
java, opencv-android-sdk
org.opencv.utils.Converters
++, opencv-, opencv-android-sdk, , converters.h converters.cpp jni , ( ).
https://github.com/Itseez/opencv/blob/master/modules/java/generator/src/cpp/converters.cpp
MatOfPoint List , ++ ( ++ MatOfPoint - std::vector < cv:: Point > ; std::vector < std::vector < cv:: Point â )
"" MatOfPoint Mat vector_Point_to_Mat Mat_to_vector_Point ( , MatOfPoint.fromList MatOfPoint )
, MatOfPoint.
Java:
public class YourJavaWrapper {
static {
System.loadLibrary("yourlibrary");
}
public static MatOfPoint findMostFencyMatOfPoints(List<MatOfPoint> contours){
List<Mat> contoursTmp = new ArrayList<Mat>(contours.size());
Mat inputMat = Converters.vector_vector_Point_to_Mat(contours, contoursTmp);
Mat outputMat = new Mat();
findMostFencyMatOfPoints(inputMat.nativeObj, outputMat.nativeObj);
List<Point> pointsTmp = new ArrayList<Point>();
Converters.Mat_to_vector_Point(outputMat, pointsTmp);
MatOfPoint matOfInterest = new MatOfPoint();
matOfInterest.fromList(pointsTmp);
outputMat.release();
return matOfInterest;
}
private static native void findMostFencyMatOfPoints(long inputMatAddress, long outPutMatAddress);
}
++:
using namespace std;
using namespace cv;
extern "C" JNIEXPORT void JNICALL Java_org_example_yourpackage_YourJavaWrapper_findMostFencyMatOfPoints(JNIEnv*, jobject, jlong inputMatAddress, jlong outPutMatAddress)
{
cv::Mat& vectorVectorPointMat = *(cv::Mat*) inputMatAddress;
std::vector< std::vector< cv::Point > > contours;
Mat_to_vector_vector_Point(vectorVectorPointMat, contours);
std::vector<cv::Point> fencyVectorOfPoints = findMostFencyVectorOfPoint(contours);
cv::Mat& largestSquareMat = *(cv::Mat*) outPutMatAddress;
vector_Point_to_Mat(fencyVectorOfPoints, outPutMatAddress);
}
findMostFencyVectorOfPoint -