Red de conocimiento informático - Conocimiento informático - Cómo convertir la tasa de MatOfPoint a MatOfPoint2f usando la API de Java en OpenCV.

Cómo convertir la tasa de MatOfPoint a MatOfPoint2f usando la API de Java en OpenCV.

1.MatOfPoint2f solo funciona con tipos (enteros de coma flotante de 32 bits y 32 bits) diferentes de MatOfPoint. Una opción viable (aunque con una penalización de rendimiento) es crear una instancia de MatOfPoint2f y establecer su velocidad (en el medio del anillo) igual a la velocidad de la fuente MatOfPoint. Hay métodos public void fromArray(Point... lp);

public Point[] toArray();

en ambas clases. Puede volver a /// variable fuente

MatOfPoint SrcMtx;

/// nueva variable

MatOfPoint2f NewMtx = new MatOfPoint2f( SrcMtx.toArray()

Imgproc.findContours(gray.cont);

Imgproc.findContours(gray.cont); findContours(gray.cont)findContours(gray, contornos, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);

for(int i=0; ilt. contours.length(); i) {

//Convierte contornos(i) de MatOfPoint a MatOfPoint2f

contours.get(i).convertTo(mMOP2f1, CvType.CV_ 32FC2);

//Procesa el mMOP2f1 de tipo MatOfPoint2f

Imgproc.approxPolyDP(mMOP2f1, mMOP2f2, approxDistance, true);

//Convierte de nuevo a MatOfPoint y vuelve a colocar el nuevo valor en la lista de esquemas

mMOP2f2.convertTo(contours.get(x), CvType.CV_32S

}

);