2016-07-30 58 views
3

我正在尝试将double[][]转换为的OpenCV积分是一个double[4][2]其坐标为四点。 我已经试过:在Java中为MatOfPoint变量添加值

MatOfPoint sourceMat = new MatOfPoint(); 
    for (int idx = 0; idx < 4; idx++) { 
    (sourceMat.get(idx, 0))[0] = pointsOrdered[idx][0]; 
    (sourceMat.get(idx, 0))[1] = pointsOrdered[idx][1]; 
} 

sourceMat值保持不变。 我试图逐个添加值,因为我还没有找到其他选项。

我该怎么办?有没有简单的方法来访问和修改MatOfPoint变量值?

感谢

+0

什么是MatOfPoint数据类型,是这种类型的OpenCV? –

+0

是的,我忘记说了,对不起。我已经更新了这个问题。 – andraga91

+0

你为什么使用MatOfPoint?您没有使用MatOfPoint的点型输入? –

回答

1

org.opencv.core.MatOfPoint预计org.opencv.core.Point对象,但它存储点的属性值(X,Y)不是Point对象本身

如果转换你的双[] [] pointsOrdered数组ArrayList的

ArrayList<Point> pointsOrdered = new ArrayList<Point>(); 
pointsOrdered.add(new Point(xVal, yVal)); 
... 

如果您有像这样的订单,您可以使用此方法从

MatOfPoint sourceMat = new MatOfPoint(); 
sourceMat.fromList(pointsOrdered); 
//your sourceMat is Ready. 
+0

它的工作原理。你救了我,谢谢! – andraga91