【问题标题】:Finding contour index using Seq(T).Item Property in EmguCV在 EmguCV 中使用 Seq(T).Item 属性查找轮廓索引
【发布时间】:2012-12-22 20:31:57
【问题描述】:

我是 EmguCV 的新手。我正在为我的应用程序使用 Emgu CV 2.4.2。我在使用 Seq(T).Item 属性查找轮廓索引时遇到问题。当我在轮廓中使用该属性时,系统会发送如下错误消息:

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

我已阅读文档here,但我不知道为什么会出现错误。这是我的代码:

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 中的其他方法找到轮廓索引。如果有人详细说明,我将不胜感激。

提前致谢, 大卫:)

【问题讨论】:

    标签: c# image-processing contour emgucv


    【解决方案1】:

    如果您查看emgu 2.4.2 docs,您会发现 Contour 类上没有 Item 属性。

    您可以做的最简单的事情是使用指示当前计数器索引的循环计数器并在循环时将其递增:

    int counter = 0;
    while (contours != null)
    {
        Console.WriteLine("contour index = {0}", counter);
        //next contour
        contours = contours.HNext; 
        counter++;
    }
    

    【讨论】:

    • 嗨卢卡。谢谢您的回复。如果你看here,你可以在页面下方找到“Item”属性。
    • 如果你仔细看here 没有真正的Item 属性,那只是经典的索引器Item 属性!!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-16
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多