利用Seq(T)求等高线索引.项目属性在EmguCV
本文关键字:项目 索引 属性 EmguCV 等高线 Seq 利用 | 更新日期: 2023-09-27 17:50:59
我是EmguCV的新手。我使用Emgu CV 2.4.2为我的应用程序。我有一个问题,找到轮廓索引使用Seq(T)。项目属性。当我在轮廓中使用该属性时,系统发送如下错误信息:
Error 11 'Emgu.CV.Contour<System.Drawing.Point>' does not contain a definition for'Item' and no
extension method 'Item' accepting a first argument of type 'Emgu.CV.Contour<System.Drawing.Point>'
could be found (are you missing a using directive or an assembly reference?) E:'TUGAS_AKHIR'headDetection'headDetection.cs 284 45 headDetection
我已经阅读了这里的文档,但我不知道为什么会出现错误。下面是我的代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.VideoSurveillance;
using Emgu.CV.CvEnum;
using Emgu.Util;
using Emgu.CV.Cvb;
using System.Collections;
//background subtraction
...
//foreFrame is the result of background subtraction
Contour<Point> contours = foreFrame.FindContours(
CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE,
RETR_TYPE.CV_RETR_EXTERNAL);
while (contours != null)
{
int idx = contours.Item; //THE ERROR MESSAGE APPEARS HERE
Console.WriteLine("contour index = {0}", idx);
//next contour
contours = contours.HNext;
}//endwhile
请帮助我如何使用Seq(T)找到轮廓索引。Item属性或EmguCV中的其他方法。如果有人能详细说明的话,我将不胜感激。
提前感谢,大卫:)
如果你看一下emgu 2.4.2文档,你会发现在Contour类上没有Item属性。
你能做的最简单的事情是使用一个循环计数器来指示当前计数器的索引,并在循环时增加它:
int counter = 0;
while (contours != null)
{
Console.WriteLine("contour index = {0}", counter);
//next contour
contours = contours.HNext;
counter++;
}