I'm trying to implement the example code of the following
question
by using opencv java api. To implement findContours(gray, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
in java i used this syntax Imgproc.findContours(gray, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
.
So now contours should be List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
rather than vector<vector<cv::Point> > contours;
.
Then i need implement this approxPolyDP(Mat(contours[i]), approx, arcLength(Mat(contours[i]), true)*0.02, true);
. In java api, Imgproc.approxPolyDP accept argument as approxPolyDP(MatOfPoint2f curve, MatOfPoint2f approxCurve, double epsilon, boolean closed)
. How i can i convert MatOfPoint to MatOfPoint2f?
Or is there a way to use vectors as same as c++ interface to implement this. Any suggestion or sample code is greatly appreciated.
question from:
https://stackoverflow.com/questions/11273588/how-to-convert-matofpoint-to-matofpoint2f-in-opencv-java-api 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…