OpenCV cvFindContours - 如何在图像中找到椭圆轮廓

时间:2013-03-13 19:08:01

标签: opencv image-processing detection javacv ellipse

我用Javacv在图片中找到米粒的图像。

enter image description here

我已经实现了这段代码:

String fileName = "image/rice.jpg";
IplImage image = cvLoadImage(fileName);
IplImage _image = cvCloneImage(image);

image = Guassian.apply(image, 3);
image = Grayscale.apply(image);
image = Threshold.apply(image, CV_THRESH_OTSU);
image = MORPH.apply(image, 7, 3, CV_MOP_ERODE);
image = MORPH.apply(image, 7, 3, CV_MOP_DILATE);
image = Canny.apply(image);

CvSeq cvSeq = new CvSeq();
CvMemStorage storage = CvMemStorage.create();

cvFindContours(image, storage, cvSeq, Loader.sizeof(CvContour.class), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
for (int i = 0; i < cvSeq.total(); i++) {
    cvEllipse(cvSeq, CvPoint.ZERO, CvSize.ZERO, i, dp, dp, CvScalar.ONE, i, i, i);
}

在第cvEllipse(cvSeq, CvPoint.ZERO, CvSize.ZERO, i, dp, dp, CvScalar.ONE, i, i, i);行中,如何设置参数?

0 个答案:

没有答案