I new to EmguCV. I am using Emgu CV 2.4.2 for my application. I've a problem to find the contour index using Seq(T).Item Property. When I used that property in contour, the system sent the error message like this :
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
I've read the documentation here, but I have no idea why the error appears. Here's my code :
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
Please help me how to find the contour index either using Seq(T).Item Property or another approach in EmguCV. I would be highly appreciate if someone elaborate it.
Thanks in advance, David :)
If you take a look at emgu 2.4.2 docs you'll see that there's no Item property on Contour class.
The simplest thing you can do is to use a loop counter that indicates current counter index and increment it while looping:
int counter = 0;
while (contours != null)
{
Console.WriteLine("contour index = {0}", counter);
//next contour
contours = contours.HNext;
counter++;
}