Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将MatOfInt转换为MatofPoint_Java_Opencv - Fatal编程技术网

Java 将MatOfInt转换为MatofPoint

Java 将MatOfInt转换为MatofPoint,java,opencv,Java,Opencv,我是OpenCV的新手,正在使用OpenCV的Java包装器。在我的应用程序中,我检测轮廓,然后围绕轮廓进行凸出。Imgproc.convexHell(马托夫点,马托芬特);以MatOfInt形式向我提供外壳线值 现在我想在我的图像中打印matofint,但是Imgproc。drawContour()需要MatOfPoint 所以我的问题是如何将MatOfInt转换为MatOfPoint公共静态MatOfPoint ConvertIndexeTopoints(MatOfPoint等高线,MatO

我是OpenCV的新手,正在使用OpenCV的Java包装器。在我的应用程序中,我检测轮廓,然后围绕轮廓进行凸出。Imgproc.convexHell(马托夫点,马托芬特);以MatOfInt形式向我提供外壳线值

现在我想在我的图像中打印matofint,但是Imgproc。drawContour()需要MatOfPoint

所以我的问题是如何将MatOfInt转换为MatOfPoint

公共静态MatOfPoint ConvertIndexeTopoints(MatOfPoint等高线,MatOfInt索引){
public static MatOfPoint convertIndexesToPoints(MatOfPoint contour, MatOfInt indexes) {
    int[] arrIndex = indexes.toArray();
    Point[] arrContour = contour.toArray();
    Point[] arrPoints = new Point[arrIndex.length];

    for (int i=0;i<arrIndex.length;i++) {
        arrPoints[i] = arrContour[arrIndex[i]];
    }

    MatOfPoint hull = new MatOfPoint(); 
    hull.fromArray(arrPoints);
    return hull; 
}
int[]arrIndex=index.toArray(); 点[]arrContour=轮廓。toArray(); 点[]arrPoints=新点[arrIndex.length];
对于(int i=0;i可能重复的)请查看答案的第二部分。它应该解释您的问题。尝试了所有方法,但没有一个有效!!!:Ophaps您应该使用(最少的)代码更新您的问题,以演示您的尝试。这样人们可以看到您所做的,并更正您可能犯的错误。