在JavaCV中为cvContourArea创建输入

时间:2013-04-02 11:56:43

标签: opencv javacv javacpp

如何创建传递给cvContourArea的轮廓?我有四个2D点,​​但不知道创建CvSeq。

int[] myPolygon = new int[] { point1.x, point1.y, point2.x, point2.y, ... };
cvCountourArea(???, null, 0);

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:

int[] myPolygon = new int[] { point1.x, point1.y, point2.x, point2.y, ... };
Mat rectMat = cvCreateMat(1, myPolygon.length/2, CV_32SC2);
rectMat.getIntBuffer().put(myPolygon);
cvCountourArea(rectMat, CV_WHOLE_SEQ, 0);
cvReleaseMat(rectMat);