Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convert MatOfPoint2f to MatOfPoint

I'm working in an opencv project for android. I need to convert a variable from MatOfPoint2f to MatOfPoint. As follows is the relevant part of my code: approx is of type MatOfPoint2f and I need to convert it because drawContours use type ArrayList<matofpoint>.

Imgproc.approxPolyDP(newMtx, approx, 0.02*peri, true);
approxMatOfPoint = (MatOfPoint) approx; // to convert
ArrayList<MatOfPoint> p = new ArrayList<>();
p.add(approxMatOfPoint);
Imgproc.drawContours(img, p, 0, new Scalar(0,255,0), 2);