我试图在OpenCV(C#)中使用ContourArea()
方法获取轮廓区域。它总是在每次迭代中为Area返回相同的值
这是我的准则的相关部分。
public void getcontour()
{
IplImage binary_image= Cv.LoadImage("binary.png", LoadMode.GrayScale);
CvMemStorage memory = new CvMemStorage();
OpenCvSharp.CvSeq<CvPoint> contours;
Cv.FindContours(binary_image, memory, out contours);
double area=0;
for (int k=0; k<=contours.Total;k++)
{
area= contours.ContourArea();
/*need to access properties such as width & height of current contour in here*/
}
//draw contours
IplImage save = Cv.CreateImage(binary_image.Size, BitDepth.U8, 1);
Cv.DrawContours(save, contours, col1, col2, 1, 1);
Cv.SaveImage("cont.png", save);
}